示例#1
0
 /**
  * Resets password.
  *
  * @param string $token
  * @return mixed
  * @throws BadRequestHttpException
  */
 public function actionResetPassword($token)
 {
     try {
         $model = new ResetPasswordForm($token);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->session->setFlash('success', 'New password was saved.');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
 /**
  **显示重设密码的表单(get),重新设置登陆密码(post).
  * @return string whether or not the password has been reset successfully
  */
 public function actionResetPassword()
 {
     if (Yii::$app->request->isGet) {
         $csrf = Yii::$app->request->csrfToken;
         return $this->render('reset-password', ['csrf' => $csrf]);
     }
     $model = new ResetPasswordForm();
     if ($model->load(Yii::$app->request->post(), '') && $model->reset()) {
         AjaxResponse::success();
     }
     AjaxResponse::fail(null, $model->errors);
 }