當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。