示例#1
0
 /**
  * Forgot password
  *
  * @return mixed
  */
 public function actionForgotPassword()
 {
     $model = new ForgotPasswordForm();
     $ret = $this->performAjaxValidation($model);
     if (is_array($ret)) {
         // AJAX validation
         return $ret;
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         /* @var $user User */
         $user = $model->getUser();
         /* @var $systemAlert Alert */
         $systemAlert = Yii::$app->systemAlert;
         // send forgot password e-mail
         if ($this->userModule->sendForgotPasswordEmail($user)) {
             $systemAlert->setMessage(Alert::INFO, Yii::t('user', 'E-mail to change password successfully sent.'));
             return $this->refresh();
         } else {
             $systemAlert->setMessage(Alert::DANGER, Yii::t('user', 'Error send an e-mail.'));
         }
     }
     return $this->render('forgot-password', ['model' => $model]);
 }