/**
  * @param string $email
  * @param string $hash
  * @return \yii\web\Response
  */
 public function actionCheck($email, $hash)
 {
     $ForgotPasswordForm = \Yii::createObject(Account\frontend\forms\ForgotPasswordForm::className());
     $ForgotPasswordForm->email = $email;
     $ForgotPasswordForm->hash = $hash;
     if ($ForgotPasswordForm->validateHash() && $ForgotPasswordForm->resetPassword()) {
         return $this->redirect(['/']);
     } else {
         return $this->redirect(['/account/forgot-password', 'bad' => 1]);
     }
 }
예제 #2
0
 /**
  * @return array
  */
 public function actionForgotPassword()
 {
     $result = ['result' => false, 'message' => ['title' => \Yii::t('account', 'Forgot password'), 'text' => \Yii::t('account', 'Unknown error.')]];
     /** @var Account\frontend\forms\ForgotPasswordForm $ForgotPasswordForm */
     $ForgotPasswordForm = \Yii::createObject(Account\frontend\forms\ForgotPasswordForm::className());
     if ($ForgotPasswordForm->load(Request()->post()) && $ForgotPasswordForm->validate() && $ForgotPasswordForm->sendNotification()) {
         $result = ['result' => true, 'message' => ['title' => \Yii::t('account', 'Forgot password'), 'text' => \Yii::t('account', 'Email with instructions sent.')]];
     }
     if ($ForgotPasswordForm->hasErrors()) {
         $result = ['result' => false, 'message' => ['title' => \Yii::t('account', 'Forgot password'), 'text' => \Yii::t('account', 'Form errors.')], 'errors' => $ForgotPasswordForm->getFirstErrors()];
     }
     return $result;
 }