public function testChangeCorrect()
 {
     /** @var User $user */
     $user = User::findOne($this->users[0]['id']);
     $form = new PasswordChangeForm($user);
     $form->setAttributes(['currentPassword' => 'adminpass', 'newPassword' => 'new-password', 'newPasswordRepeat' => 'new-password']);
     expect('password is changed', $form->changePassword())->true();
     expect('password is correct', $user->validatePassword('new-password'))->true();
 }
Beispiel #2
0
 public function actionPasswordChange()
 {
     $user = $this->findModel();
     $model = new PasswordChangeForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->changePassword()) {
         Yii::$app->getSession()->setFlash('success', Module::t('module', 'FLASH_PASSWORD_CHANGE_SUCCESS'));
         return $this->redirect(['index']);
     } else {
         return $this->render('passwordChange', ['model' => $model]);
     }
 }