コード例 #1
0
ファイル: SiteController.php プロジェクト: specialnote/myYii
 /**
  * 修改面膜
  * @return string|\yii\web\Response
  */
 public function actionPassword()
 {
     if (Yii::$app->user->isGuest) {
         return $this->redirect(['/site/login']);
     }
     $model = new ResetPasswordForm(Yii::$app->user->identity->password_reset_token);
     if ($model->load(Yii::$app->request->post()) && $model->resetPassword()) {
         Yii::$app->user->logout();
         return $this->redirect(['/site/login']);
     }
     return $this->render('password', ['model' => $model]);
 }
コード例 #2
0
 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->getSession()->setFlash('success', 'New password was saved.');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }