当前位置: 首页>>代码示例>>PHP>>正文


PHP LoginForm::getUser方法代码示例

本文整理汇总了PHP中common\models\LoginForm::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm::getUser方法的具体用法?PHP LoginForm::getUser怎么用?PHP LoginForm::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\LoginForm的用法示例。


在下文中一共展示了LoginForm::getUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRole

 public static function getRole()
 {
     $mode = new LoginForm();
     $mode->username = \Yii::$app->user->identity->username;
     $role;
     $user = new User();
     if ($user = $mode->getUser()) {
         $role = $user->role;
     } else {
         $role = null;
     }
     return $role;
 }
开发者ID:andrenovelando,项目名称:firewall-webapps,代码行数:13,代码来源:priviledge.php

示例2: actionLogin

 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $user = $model->getUser();
         //set name in session
         Yii::$app->session->set('user.name', $user['firstname']);
         $type = $user['type'];
         if ($type == 'Tutor' || $type == 'tutor') {
             return $this->redirect('index.php?r=file/index');
         } else {
             return $this->render('studentHome');
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:vihanga-liyanage,项目名称:feed-cloud,代码行数:25,代码来源:SiteController.php

示例3: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $_user = new User();
         if ($_user = $model->getUser()) {
             if ($_user->role == 'Admin') {
                 $model->login();
                 return $this->goHome();
             } else {
                 return $this->render('login', ['model' => $model]);
             }
         } else {
             return $this->render('login', ['model' => $model]);
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:andrenovelando,项目名称:firewall-webapps,代码行数:22,代码来源:SiteController.php

示例4: actionCreate

 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (($role = priviledge::getRole()) == 'Admin') {
         $model = new Task();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             $model->url = strtolower($model->url);
             $model->status = 'Pending';
             //$model->user_id = \Yii::$app->user->identity;
             $mode = new LoginForm();
             $mode->username = \Yii::$app->user->identity->username;
             $user = new User();
             if ($user = $mode->getUser()) {
                 $model->user_id = $user->id;
             }
             $listsocmed = $_POST['Task']['socmed'];
             $model->facebook = 'No';
             $model->twitter = 'No';
             foreach ($listsocmed as $value) {
                 if ($value == 'Facebook') {
                     $model->facebook = 'Yes';
                 }
                 if ($value == 'Twitter') {
                     $model->twitter = 'Yes';
                 }
             }
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->task_id]);
             } else {
                 return $this->render('create', ['model' => $model]);
             }
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
开发者ID:andrenovelando,项目名称:firewall-webapps,代码行数:42,代码来源:TaskController.php

示例5: LoginForm

<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\BadRequestHttpException;
use common\models\LoginForm;
use common\models\User;
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$user = new User();
if (!($user = $mode->getUser())) {
    throw new BadRequestHttpException();
}
$this->title = 'Homepage ' . $user->role;
?>
<div class="site-index">

    <div class="jumbotron">
        <h2>Selamat Datang di Halaman <?php 
echo $user->role;
?>
 !</h2>
    </div>

</div>
开发者ID:andrenovelando,项目名称:firewall-webapps,代码行数:26,代码来源:index.php

示例6: actionLoginAuth

 public function actionLoginAuth($auth_key = null, $username = null)
 {
     if ($auth_key !== null && $username !== null) {
         $model = new LoginForm();
         $model->username = $username;
         if ($user = $model->getUser()) {
             if ($user->auth_key === $auth_key) {
                 if (Yii::$app->user->login($user) !== null) {
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->redirect(['/site/login']);
 }
开发者ID:adzadzadz,项目名称:yii2-strepz,代码行数:15,代码来源:SiteController.php


注:本文中的common\models\LoginForm::getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。