public function actionPasswordChange()
 {
     $user = $this->findModel();
     $model = new PasswordChangeForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->changePassword()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('passwordChange', ['model' => $model]);
     }
 }
Example #2
0
 public function actionPasswordChange($token)
 {
     try {
         $model = new PasswordChangeForm($token);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException('Wrong password reset token.');
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && $model->changePassword()) {
             Alert::addSuccess('New password was saved.');
             return $this->goHome();
         } else {
             Alert::addError('Password hasn\'t been saved.');
             return $this->goHome();
         }
     }
     return $this->render('password-change', ['model' => $model]);
 }