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


PHP User::findByPasswordResetToken方法代码示例

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


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

示例1: __construct

 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if ($token === '') {
         throw new InvalidParamException('Токен для сброса пароля не может быть пустым');
     }
     if (!($this->_user = User::findByPasswordResetToken($token))) {
         throw new InvalidParamException('Неправильный токен сброса пароля');
     }
     parent::__construct($config);
 }
开发者ID:Sywooch,项目名称:notes,代码行数:17,代码来源:ResetPasswordForm.php

示例2: __construct

 /**
  * Creates a form model given a token.
  *
  * @param string $token  Password reset token.
  * @param array  $config Name-value pairs that will be used to initialize the object properties.
  *
  * @throws \yii\base\InvalidParamException  If token is empty or not valid.
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException(Yii::t('app', 'Password reset token cannot be blank.'));
     }
     $this->_user = User::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException(Yii::t('app', 'Wrong password reset token.'));
     }
     parent::__construct($config);
 }
开发者ID:elevatesolutions,项目名称:proverbs,代码行数:19,代码来源:ResetPasswordForm.php

示例3: validateToken

 /**
  * Validate token
  *
  * @param string $token
  * @return boolean
  */
 public function validateToken($token)
 {
     if (empty($token) || !is_string($token)) {
         return false;
     }
     $this->user = User::findByPasswordResetToken($token);
     if (!$this->user) {
         return false;
     }
     return true;
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:17,代码来源:ResetPasswordForm.php

示例4: InvalidParamException

 function __construct($key, $config = [])
 {
     if (empty($key) || !is_string($key)) {
         throw new InvalidParamException('Ключ не может быть пустым');
     }
     $this->_user = User::findByPasswordResetToken($key);
     if (!$this->_user) {
         throw new InvalidParamException('Неверный ключ');
     }
     parent::__construct($config);
 }
开发者ID:silischev,项目名称:yii2_blog,代码行数:11,代码来源:RecoveryPasswordForm.php

示例5: __construct

 /**
  * Creates a form model given a token.
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $password, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Ключ для восстановления пароля не найден.');
     }
     if (empty($password) || !is_string($password)) {
         throw new InvalidParamException('Пароль не задан.');
     }
     $this->_user = User::findByPasswordResetToken($token);
     $this->password = $password;
     if (!$this->_user) {
         throw new InvalidParamException('Неправильный ключ для восстановления пароля.');
     }
     parent::__construct($config);
 }
开发者ID:Shekhovtsovy,项目名称:yii2-start-auth-app,代码行数:21,代码来源:ResetPassword.php

示例6: actionChangepass

 public function actionChangepass()
 {
     if (!($post = \Yii::$app->getRequest()->getBodyParams())) {
         throw new \yii\web\HttpException(400, 'No data was posted');
     }
     $model = User::findByPasswordResetToken($post['token']);
     if (!$model) {
         throw new \yii\web\HttpException(422, 'Password reset token is not valid');
     }
     $password = $post['password'];
     $validator = new \yii\validators\StringValidator(['min' => 3, 'max' => 12]);
     if (!$validator->validate($password, $error)) {
         throw new \yii\web\HttpException(422, $error);
     }
     $model->setPassword($post['password']);
     $model->removePasswordResetToken();
     $model->save();
     echo $model->username;
     exit('ok');
 }
开发者ID:Vitashev,项目名称:resource-app,代码行数:20,代码来源:UserController.php

示例7: actionReset

 public function actionReset($token)
 {
     $user = User::findByPasswordResetToken($token);
     $model = new ResetForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user) {
             $user->removePasswordResetToken();
             $user->password = md5($model->password);
             $user->save();
             Yii::$app->getSession()->setFlash('success', 'Su password ha sido cambiado con éxito.');
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('warning', 'El token de seguridad es inválido o ya ha expirado.');
             return $this->goHome();
         }
     }
     return $this->render('reset', ['model' => $model]);
 }
开发者ID:frankpaul142,项目名称:chaide,代码行数:18,代码来源:SiteController.php

示例8: actionChangepass

 public function actionChangepass()
 {
     /*        echo \Yii::$app->session->get('role');
             exit('d');*/
     if (!($post = \Yii::$app->getRequest()->getBodyParams())) {
         throw new \yii\web\HttpException(400, 'Дані не отримані');
     }
     $model = User::findByPasswordResetToken($post['token']);
     if (!$model) {
         throw new \yii\web\HttpException(422, 'Ключ для відновлення паролю не є коректним');
     }
     $password = $post['password'];
     $validator = new \yii\validators\StringValidator(['min' => 3, 'max' => 12, 'tooShort' => 'Пароль повинен містити мінімум {min, number} символи', 'tooLong' => 'Пароль повинен містити не більше {max, number} символів']);
     if (!$validator->validate($password, $error)) {
         throw new \yii\web\HttpException(422, $error);
     }
     $model->setPassword($password);
     $model->removePasswordResetToken();
     $model->save();
     echo $model->username;
     exit('ok');
 }
开发者ID:romangrb,项目名称:resource-registry,代码行数:22,代码来源:UserController.php

示例9: actionNewPassword

 /**
  * установить новый пароль
  * @param type $token
  * @return type
  */
 public function actionNewPassword($token)
 {
     $user = User::findByPasswordResetToken($token);
     if ($user) {
         $user->setNewPassword();
         Yii::$app->getSession()->setFlash('success', 'Новый пароль выслан на почту');
     } else {
         Yii::$app->getSession()->setFlash('error', 'Токен не действителен');
     }
     return $this->goHome();
 }
开发者ID:nicdnepr,项目名称:skidos,代码行数:16,代码来源:SiteController.php

示例10: testFindByPasswordResetToken

 public function testFindByPasswordResetToken()
 {
     $user = $this->tester->grabFixture('user', 'user-1');
     expect_that($user = User::findByPasswordResetToken($user->password_reset_token));
     expect($user->username)->equals('superuser');
     expect_not(User::findByPasswordResetToken(999));
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:7,代码来源:UserTest.php


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