public function actionChangePassword() { $user = $this->findModel(); $model = new ChangePasswordForm($user); if ($model->load(Yii::$app->request->post()) && $model->changePassword()) { return $this->redirect(['index']); } else { return $this->render('changePassword', ['model' => $model]); } }
public function actionChangePassword() { $this->layout = '/main'; $changePasswordModel = new ChangePasswordForm(); $success = false; if ($changePasswordModel->load(Yii::$app->request->post()) && $changePasswordModel->changePassword()) { $success = true; $changePasswordModel = new ChangePasswordForm(); } return $this->render('change-password', ['model' => $changePasswordModel, 'success' => $success]); }
public function actionChangePassword() { try { $model = new ChangePasswordForm(); } catch (Exception $e) { return $this->goHome(); //throw new ForbiddenHttpException($e->getMessage()); } if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->changePassword()) { Yii::$app->getSession()->setFlash('success', 'New password was saved.'); return $this->goHome(); } return $this->render('changePassword', ['model' => $model]); }