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


PHP LoginForm::getUser方法代码示例

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


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

示例1: testGetUser

 public function testGetUser()
 {
     // failure
     $model = new LoginForm();
     $model->username = 'wrong_username';
     $this->assertNull($model->getUser());
     // success
     $model = new LoginForm();
     $model->username = $this->users['user1']['username'];
     $this->assertInstanceOf('app\\models\\User', $model->getUser());
 }
开发者ID:highestgoodlikewater,项目名称:yii2-englishwordbook-demo,代码行数:11,代码来源:LoginFormTest.php

示例2: actionLogin

 public function actionLogin()
 {
     $model = new LoginForm();
     $data = Yii::$app->request->post();
     $model->load($data, '');
     if ($model->login()) {
         $user = $model->getUser();
         return ['token' => $user->token];
     } else {
         Yii::$app->response->statusCode = 401;
         return ['errors' => $this->filterErrors($model->getErrors())];
     }
 }
开发者ID:AndriyK,项目名称:team,代码行数:13,代码来源:AuthController.php

示例3: actionLogin

 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         $user = User::findOne(Yii::$app->user->id);
         return json_encode(['success' => true, 'data' => $user->attributes]);
     }
     $login = new LoginForm();
     $login->email = Yii::$app->request->post('email');
     $login->password = Yii::$app->request->post('password');
     if ($login->login()) {
         $user = $login->getUser();
         return json_encode(['success' => true, 'data' => $user->attributes]);
     } else {
         if ($login->hasErrors()) {
             return json_encode(['success' => false, 'data' => $login->getErrors()]);
         }
     }
 }
开发者ID:shinzero999,项目名称:Eveda-yii,代码行数:18,代码来源:SiteController.php

示例4: actionLogin

 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->afterLogin();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $user = $model->getUser();
         if ($user->status != User::STATUS_ACTIVE) {
             Yii::$app->user->logout();
             Yii::$app->session->setFlash('error', 'Your account is not active.');
             return $this->refresh();
         }
         if ($user->role >= User::ROLE_STAFF) {
             return $this->redirect(['/admin']);
         } else {
             Yii::$app->user->logout();
             Yii::$app->session->setFlash('error', 'You do not have permission.');
             return $this->refresh();
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:shinzero999,项目名称:Eveda-yii,代码行数:24,代码来源:DefaultController.php

示例5: actionReset

 /**
  * Send email link to access reset password
  * @return type mixed
  */
 public function actionReset()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     //if request is post
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->getUser()) {
             //Found user
             \Yii::$app->notification->sendMail($user->identity, 4, ['{{name}}' => $user->profile->first_name, '{{link}}' => Html::a('This URL', Yii::$app->urlManager->createAbsoluteUrl(['admin/changesecurity/', 'token' => base64_encode($user->access_token)]))]);
             Yii::$app->session->setFlash('success', 'We have sent an email with the reset link! Please check it out.');
             $model = new LoginForm();
         } else {
             //No user exists
             Yii::$app->session->setFlash('error', 'You are not a member!');
         }
     }
     return $this->render('reset', ['model' => $model]);
 }
开发者ID:livingdreams,项目名称:kidcrossing,代码行数:24,代码来源:AdminController.php

示例6: actionReset

 /**
  * Send email link to access reset password
  * @return void mixed
  */
 public function actionReset()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     //if request is post
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->getUser()) {
             //Found user
             if ($user->level == 3) {
                 $params = ['{{name}}' => $user->parent->profile->first_name, '{{child}}' => $user->profile->label . ' "' . $user->fullname . '"', '{{link}}' => Html::a('Click', Yii::$app->urlManager->createAbsoluteUrl(['user/family/', 'id' => $user->id]))];
                 \Yii::$app->notification->sendMail($user->parent->identity, 5, $params);
                 Yii::$app->session->setFlash('success', 'We have sent an email to your parent! Please ask to reset your password.');
             } else {
                 $params = ['{{name}}' => $user->profile->first_name, '{{link}}' => Html::a('This URL', Yii::$app->urlManager->createAbsoluteUrl(['user/changesecurity/', 'token' => base64_encode($user->access_token)]))];
                 \Yii::$app->notification->sendMail($user->identity, 4, $params);
                 Yii::$app->session->setFlash('success', 'We have sent an email with the reset link! Please check it out.');
             }
             $model = new LoginForm();
         } else {
             //No user exists
             Yii::$app->session->setFlash('error', 'You are not a member!');
         }
     }
     return $this->render('reset', ['model' => $model]);
 }
开发者ID:livingdreams,项目名称:kidcrossing,代码行数:31,代码来源:UserController.php


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