public function actionPassword()
 {
     $user = $this->findModel();
     $model = new PasswordChangeForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->changePassword()) {
         Yii::$app->getSession()->setFlash('success', Module::t('app', 'FLASH_PASSWORD_CHANGE_SUCCESS'));
         return $this->redirect(['index']);
     } else {
         return $this->render('password', ['model' => $model]);
     }
 }
示例#2
0
 public function actionIndex()
 {
     $user = $this->findModel();
     $profile = $user->profile;
     $passwordChangeForm = new PasswordChangeForm($user);
     $profileChangeForm = new ProfileChangeForm($profile);
     $postData = Yii::$app->request->post();
     $session = Yii::$app->getSession();
     if ($passwordChangeForm->load($postData) && $passwordChangeForm->changePassword()) {
         $session->setFlash('success', Yii::t('user/password', 'The password has been successfully updated'));
         $passwordChangeForm = new PasswordChangeForm($user);
     }
     if ($profileChangeForm->load($postData) && $profileChangeForm->update()) {
         $session->setFlash('success', Yii::t('user/password', 'The profile has been successfully updated'));
     }
     return $this->render('index', ['passwordChangeForm' => $passwordChangeForm, 'profileChangeForm' => $profileChangeForm]);
 }