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


PHP User::findByEmail方法代码示例

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


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

示例1: findUser

 /**
  * @param $userEmail
  *
  * @return null|static|User
  */
 protected function findUser($userEmail)
 {
     if (!($user = User::findByEmail($userEmail))) {
         throw new InvalidParamException("Not found user by email {$userEmail}");
     }
     return $user;
 }
开发者ID:starcode-solutions,项目名称:star-tracker,代码行数:12,代码来源:RbacController.php

示例2: actionIndex

 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         $model = new IndexForm();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             if ($link = $model->generateLink()) {
                 if (User::findByEmail($link->email)) {
                     $url = Yii::$app->urlManager->createAbsoluteUrl(['/site/login', 'token' => $link->token]);
                 } else {
                     $url = Yii::$app->urlManager->createAbsoluteUrl(['/site/reg', 'token' => $link->token]);
                 }
                 if ($model->sendMail($url, $link->email)) {
                     Yii::$app->session->setFlash('warning', 'Check your email');
                     return $this->redirect('/site/index');
                 }
             } else {
                 Yii::$app->session->setFlash('error', 'Error generate link.');
                 Yii::error('Error generate link');
                 return $this->refresh();
             }
         }
         return $this->render('index', ['model' => $model]);
     }
     return $this->redirect('/account/index');
 }
开发者ID:andrey3,项目名称:yii,代码行数:25,代码来源:SiteController.php

示例3: getUser

 /**
  * Finds user by [[email]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByEmail($this->email);
     }
     return $this->_user;
 }
开发者ID:sindotnet,项目名称:cona,代码行数:12,代码来源:LoginForm.php

示例4: getUser

 public function getUser()
 {
     if ($this->_user === false) {
         //            $this->_user = User::findByUsername($this->username);
         $this->_user = User::findByEmail($this->email);
     }
     return $this->_user;
 }
开发者ID:silischev,项目名称:yii2_blog,代码行数:8,代码来源:LoginForm.php

示例5: findUser

 public function findUser()
 {
     $this->_user = User::findByEmail($this->email);
     if (!$this->_user) {
         return false;
     }
     return true;
 }
开发者ID:feijilei,项目名称:simpleforum,代码行数:8,代码来源:ForgotPasswordForm.php

示例6: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
         if (is_null($this->_user)) {
             $this->_user = User::findByEmail($this->username);
         }
     }
     return $this->_user;
 }
开发者ID:jeandias,项目名称:yii2-basic,代码行数:15,代码来源:LoginForm.php

示例7: testSuccess

 public function testSuccess()
 {
     $user = User::findByEmail('superuser@example.com');
     expect_not($user->isConfirmed());
     $form = new ConfirmEmailForm();
     expect_that($form->validateToken($user->email_confirm_token));
     expect_that($form->confirmEmail());
     $user = User::findByEmail($user->email);
     expect($user->email_confirm_token)->isEmpty();
     expect_that($user->isConfirmed());
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:11,代码来源:ConfirmEmailFormTest.php

示例8: testSuccess

 public function testSuccess()
 {
     $user = $this->tester->grabFixture('user', 'user-1');
     $form = new ResetPasswordForm();
     $form->password = 'password-new';
     expect_that($form->validateToken($user->password_reset_token));
     expect_that($form->resetPassword());
     $user = User::findByEmail($user->email);
     expect($user->password_reset_token)->isEmpty();
     expect_that($user->validatePassword('password-new'));
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:11,代码来源:ResetPasswordFormTest.php

示例9: getUser

 public function getUser()
 {
     if ($this->_user === false) {
         if ($this->scenario === 'loginWithEmail') {
             $this->_user = User::findByEmail($this->email);
         } else {
             $this->_user = User::findByUsername($this->username);
         }
     }
     return $this->_user;
 }
开发者ID:karliv,项目名称:our_yii_app,代码行数:11,代码来源:LoginForm.php

示例10: sendEmail

 /**
  * Send password reset instructions.
  * @return boolean
  */
 public function sendEmail()
 {
     $user = User::findByEmail($this->email);
     if ($user && $user->status === User::STATUS_ENABLED) {
         $user->generatePasswordResetToken();
         if ($user->save()) {
             return $this->mail('passwordRequest', $this->email, ['subject' => Yii::t('app', 'Reset password information for {name} at {site}', ['name' => $user->name, 'site' => Yii::$app->name]), 'user' => $user]);
         }
     }
     return false;
 }
开发者ID:skoro,项目名称:yii2-admin-template,代码行数:15,代码来源:PasswordRequest.php

示例11: login

 public function login()
 {
     if ($this->validate()) {
         if (!($user = User::findByUsername($this->username))) {
             $user = User::findByEmail($this->username);
         }
         if ($login = \Gbox::$components->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0)) {
         }
         return $login;
     }
     return false;
 }
开发者ID:roxgueldevs,项目名称:gboxframework,代码行数:12,代码来源:FormAccountSignIn.php

示例12: actionIndex

 public function actionIndex()
 {
     $params = Yii::$app->request->getBodyParams();
     $user = User::findByEmail(Yii::$app->request->getBodyParam('email'));
     if (!$user) {
         return ['success' => 0, 'message' => 'No such user found'];
     }
     $valid = $user->validatePassword(Yii::$app->request->getBodyParam('password'));
     if (!$valid) {
         return ['success' => 0, 'message' => 'Incorrect password'];
     }
     return ['success' => 1, 'payload' => $user];
 }
开发者ID:aniruddhanath,项目名称:yii2-rest-api,代码行数:13,代码来源:LoginController.php

示例13: authenticate

 public function authenticate($data)
 {
     $user = User::findByEmail($data->email);
     if (empty($user)) {
         throw new Exception('Такой пользователь не существует', self::ERROR_INVALID_EMAIL);
     }
     if (!\T4\Crypt\Helpers::checkPassword($data->password, $user->password)) {
         throw new Exception('Неверный пароль', self::ERROR_INVALID_PASSWORD);
     }
     $this->login($user);
     Application::getInstance()->user = $user;
     return $user;
 }
开发者ID:pr-of-it,项目名称:profit,代码行数:13,代码来源:Identity.php

示例14: restorePsw

 public function restorePsw()
 {
     $user = User::findByEmail($this->email);
     if ($user) {
         if ($user->password_reset_token === '') {
             $user->password_reset_token = Yii::$app->security->generateRandomString();
             $user->save();
         }
         $this->sendEmail($this->email, $user->id, $user->password_reset_token);
         return true;
     }
     return false;
 }
开发者ID:Bibihelper,项目名称:Project2015,代码行数:13,代码来源:RestorePswForm.php

示例15: resetPassword

 public function resetPassword()
 {
     if ($this->validate()) {
         $user = User::findByEmail($this->email, true);
         if (is_null($user)) {
             $this->addError('email', '无效的邮箱');
             return false;
         }
         $user->salt = Str::random(10);
         $user->password = $user->generatePassword($this->password);
         return $user->save();
     }
     $this->addError('password', '重置密码失败');
     return false;
 }
开发者ID:NikDevPHP,项目名称:yii2-blog,代码行数:15,代码来源:SignUpForm.php


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