Inheritance: extends yii\base\Model
コード例 #1
0
 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->getSession()->setFlash('success', 'Your password has been reset successfully.');
         return $this->redirect(array('/auth/login/'));
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: KanKai/dsale2015
 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->getSession()->setFlash('success', 'New password was saved.');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #3
0
 public function testResetCorrectToken()
 {
     $form = new ResetPasswordForm($this->user[0]['password_reset_token']);
     expect('password should be resetted', $form->resetPassword())->true();
 }
コード例 #4
0
 /**
  * set new password
  * @param $token
  * @return string|\yii\web\Response
  */
 public function actionResetConfirm($token)
 {
     $this->layout = 'login';
     $model = new ResetPasswordForm();
     $account = Account::findByPasswordResetToken($token);
     if ($account) {
         if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->setPassword($account)) {
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'New password was saved.'));
             return $this->redirect(['/account/login']);
         }
     }
     return $this->render('reset-confirm', ['model' => $model, 'account' => $account]);
 }
コード例 #5
0
 public function actionResetPassword($token)
 {
     try {
         $model = new ResetPasswordForm($token);
     } catch (InvalidParamException $e) {
         Yii::$app->getSession()->setFlash('danger', ['type' => 'danger', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-exclamation-sign', 'message' => 'Parámetro inválido', 'title' => 'Reestablecer contraseña', 'positonY' => 'top', 'positonX' => 'center']);
         return $this->goHome();
         //throw new BadRequestHttpException($e->getMessage()); al mostrar el error lo hace en el layout main en vez de landing
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->getSession()->setFlash('success', ['type' => 'success', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-user', 'message' => 'La contraseña se ha guardado con éxito.', 'title' => 'Reestablecer contraseña', 'positonY' => 'top', 'positonX' => 'center']);
         return $this->goHome();
     }
     $user = User::findByPasswordResetToken($token);
     if (!$user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     return $this->renderAjax('resetPassword', ['model' => $model, 'user' => $user]);
 }
コード例 #6
0
 /**
  * Resets password.
  *
  * @param string $token
  * @return mixed
  */
 public function actionResetPassword($token)
 {
     $model = new ResetPasswordForm(['token' => $token]);
     if (!$model->validate(['token'])) {
         Yii::$app->session->addFlash('error', Yii::t('authorization', 'Wrong password reset token provided. {0}', [Html::a(Yii::t('authorization', 'Resend?'), ['site/request-password-reset'])]));
         return $this->goHome();
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->session->addFlash('success', Yii::t('frontend', 'New password was saved. You can login now.'));
         return $this->redirect(['login']);
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #7
0
 public function testResetCorrectToken()
 {
     $user = $this->tester->grabFixture('user', 0);
     $form = new ResetPasswordForm($user['password_reset_token']);
     expect_that($form->resetPassword());
 }
コード例 #8
0
 public function actionResetPassword()
 {
     $model = new ResetPasswordForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->getSession()->setFlash('success', '密码修改成功');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #9
0
ファイル: SiteController.php プロジェクト: an2riy/purina
 public function actionResetPassword($uid, $token)
 {
     $model = new ResetPasswordForm($uid, $token);
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->validate()) {
             try {
                 if ($model->resetPassword()) {
                     Yii::$app->getSession()->setFlash('success', 'Пароль успешно изменен.');
                     return $this->redirect([$this->id . '/login']);
                 } else {
                     Yii::$app->getSession()->setFlash('error', 'Не удалось изменить пароль.');
                     return $this->refresh();
                 }
             } catch (\Exception $e) {
                 Yii::$app->getSession()->setFlash('error', 'Не удалось изменить пароль.');
                 return $this->refresh();
             }
         }
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #10
0
ファイル: SiteController.php プロジェクト: MaxFlower/kklk
 /**
  * Resets password.
  *
  * @param string $token
  * @return mixed
  * @throws BadRequestHttpException
  */
 public function actionResetPassword($token)
 {
     try {
         $model = new ResetPasswordForm($token);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     $this->layout = 'empty_layout';
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->session->setFlash('success', 'Новый пароль сохранен.');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #11
0
ファイル: AccountController.php プロジェクト: npk/v2sex
 public function actionResetPassword($token)
 {
     $this->title = '重置密码' . ' - ' . Yii::$app->name;
     $this->description = '';
     try {
         $model = new ResetPasswordForm($token);
     } catch (InvalidParamException $e) {
         throw new NotFoundHttpException($e->getMessage());
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
         Yii::$app->getSession()->setFlash('success', '重置密码成功。');
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #12
0
ファイル: SiteController.php プロジェクト: suyuanen/p2p
 public function actionChangePassword()
 {
     $request = wanhunet::$app->request;
     if ($request->isPost) {
         $resetPass = new ResetPasswordForm($request->post());
         if ($resetPass->validate()) {
             if ($resetPass->save()) {
                 return $this->goBack(['info' => '修改成功'], Url::to(['site/setup']));
             }
         } else {
             if ($resetPass->hasErrors()) {
                 return $this->goBack(['info' => current($resetPass->getFirstErrors())], Url::to(['site/change-password']));
             }
         }
     }
     return $this->view('change_password');
 }
コード例 #13
0
ファイル: MainController.php プロジェクト: baranov-nt/some-2
 public function actionResetPassword($key)
 {
     try {
         $model = new ResetPasswordForm($key);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && $model->resetPassword()) {
             Yii::$app->getSession()->setFlash('warning', 'Пароль изменен.');
             return $this->redirect(['/main/login']);
         }
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #14
0
 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->getSession()->setFlash('success', 'Пароль успешно изменён.');
         return $this->redirect('/site/login');
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
コード例 #15
0
ファイル: SiteController.php プロジェクト: jedzura/nzs
 /**
  * Resets password.
  *
  * @param string $token
  * @return mixed
  * @throws BadRequestHttpException
  */
 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()) {
         Alert::add(Yii::t('msg', 'New password was saved. Now you can log in.'));
         return $this->goHome();
     }
     return $this->render('resetPassword', ['model' => $model]);
 }