/** * Resets password. * @param string $token password reset token * @return mixed response * @throws BadRequestHttpException on invalid token. */ 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->session->setFlash('success', 'New password was saved.'); return $this->redirect(Yii::$app->user->loginUrl); } return $this->render('resetPassword', ['model' => $model]); }
public function testResetCorrectToken() { $form = new ResetPasswordForm($this->user[0]['passwordResetToken']); expect('password should be resetted', $form->resetPassword())->true(); }