Ejemplo n.º 1
0
 public function testCorrectResetPassword()
 {
     $user = UserModel::findOne(['email' => '*****@*****.**']);
     $this->_model = new ResetPasswordForm($user, ['password' => '123456', 'confirmPassword' => '123456']);
     expect($this->_model->resetPassword())->true();
     expect($this->_model->errors)->isEmpty();
 }
Ejemplo n.º 2
0
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = UserModel::findOne(['status' => UserModel::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         $user->generatePasswordResetToken();
         if ($user->save()) {
             return \Yii::$app->mail->compose('passwordResetToken', ['user' => $user])->setFrom(\Yii::$app->params['adminEmail'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }