當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\PasswordResetRequestForm類代碼示例

本文整理匯總了PHP中frontend\models\PasswordResetRequestForm的典型用法代碼示例。如果您正苦於以下問題:PHP PasswordResetRequestForm類的具體用法?PHP PasswordResetRequestForm怎麽用?PHP PasswordResetRequestForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PasswordResetRequestForm類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $this->layout = 'login';
     $model = new LoginForm();
     $passResetModel = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         if ($passResetModel->load(Yii::$app->request->post()) && $passResetModel->validate()) {
             /*Yii::$app->mailer->compose()
                  ->setFrom('test@gmail.com')
                  ->setTo('trantor.php@gmail.com')
                  ->setSubject('Email sent from Yii2-Swiftmailer')
             	 ->setTextBody('asdfasdasd')
                  ->send();*/
             if ($passResetModel->sendEmail()) {
                 Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.');
                 return $this->goHome();
             } else {
                 Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
                 return $this->goBack();
             }
         } else {
             return $this->render('login', ['model' => $model, 'passResetModel' => $passResetModel]);
         }
     }
 }
開發者ID:soodsse,項目名稱:YII2demo,代碼行數:30,代碼來源:SiteController.php

示例2: actionRequestPasswordReset

 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.');
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:KanKai,項目名稱:dsale2015,代碼行數:13,代碼來源:UserController.php

示例3: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', 'Данные для восстановления отправлены на Ваш E-mail');
             return $this->goHome();
         } else {
             Yii::$app->session->setFlash('error', 'К сожалению, такой адрес не существует');
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:BCxTIM,項目名稱:myblog,代碼行數:18,代碼來源:SiteController.php

示例4: testSendEmailSuccessfully

 public function testSendEmailSuccessfully()
 {
     $userFixture = $this->tester->grabFixture('user', 0);
     $model = new PasswordResetRequestForm();
     $model->email = $userFixture['email'];
     $user = User::findOne(['password_reset_token' => $userFixture['password_reset_token']]);
     expect_that($model->sendEmail());
     expect_that($user->password_reset_token);
     $emailMessage = $this->tester->grabLastSentEmail();
     expect('valid email is sent', $emailMessage)->isInstanceOf('yii\\mail\\MessageInterface');
     expect($emailMessage->getTo())->hasKey($model->email);
     expect($emailMessage->getFrom())->hasKey(Yii::$app->params['supportEmail']);
 }
開發者ID:yiisoft,項目名稱:yii2-app-advanced,代碼行數:13,代碼來源:PasswordResetRequestFormTest.php

示例5: actionRequestPasswordReset

 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('resultSentMail', 'Проверьте ваш Email для дальнейших инструкций.');
             return $this->redirect(Yii::$app->request->referrer);
             //return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('resultSentMail', 'Мы не смогли обновить пароль для вашего Email.');
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:kibercoder,項目名稱:bilious-octo-fibula,代碼行數:14,代碼來源:AccessController.php

示例6: testSendEmailCorrectUser

 public function testSendEmailCorrectUser()
 {
     $model = new PasswordResetRequestForm();
     $model->email = $this->user[0]['email'];
     $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]);
     expect('email sent', $model->sendEmail())->true();
     expect('user has valid token', $user->password_reset_token)->notNull();
     $this->specify('message has correct format', function () use($model) {
         expect('message file exists', file_exists($this->getMessageFile()))->true();
         $message = file_get_contents($this->getMessageFile());
         expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
         expect('message "to" is correct', $message)->contains($model->email);
     });
 }
開發者ID:sciurodont,項目名稱:yii2,代碼行數:14,代碼來源:PasswordResetRequestFormTest.php

示例7: actionRequestPasswordReset

 public function actionRequestPasswordReset()
 {
     $this->title = '找回密碼' . ' - ' . Yii::$app->name;
     $this->description = '';
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', '郵件發送成功!請檢查您的電子郵箱以獲得進一步操作說明。');
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', '很抱歉,我們無法提供密碼重置郵件。');
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:npk,項目名稱:v2sex,代碼行數:15,代碼來源:AccountController.php

示例8: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', Yii::t('app', 'RESET_PASSWORD_CHECK_MAIL_INSTRUCTIONS'));
             return $this->goHome();
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'ERROR_SEND_EMAIL'));
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:BCxTIM,項目名稱:myblog,代碼行數:18,代碼來源:SiteController.php

示例9: actionRequestPasswordReset

 public function actionRequestPasswordReset($type = 'sms', $step = '1')
 {
     if ($type === 'sms') {
         $session = Yii::$app->session;
         $session->open();
         if ($step !== '2') {
             $model = new PasswordResetMobileRequestForm();
             if ($model->load(Yii::$app->request->post()) && $model->validate()) {
                 if ($model->sendMsg()) {
                     $session['passwordResetTimeout'] = time() + 900;
                     // 15 minutes
                     $session['passwordResetMobile'] = $model->mobile;
                     return $this->redirect(['request-password-reset', 'type' => $type, 'step' => '2']);
                 } else {
                     $session->setFlash('smsFailure', '對不起,驗證碼發送失敗。');
                 }
             }
         } elseif (isset($session['passwordResetTimeout']) && $session['passwordResetTimeout'] >= time()) {
             $model = new PasswordResetVerifyForm();
             $model->load(Yii::$app->request->post());
             if (Yii::$app->request->isAjax) {
                 Yii::$app->response->format = Response::FORMAT_JSON;
                 return ActiveForm::validate($model);
             }
             if (Yii::$app->request->isPost && $model->validate()) {
                 if ($model->generateToken()) {
                     $model->clearSession();
                     return $this->redirect(['reset-password', 'token' => $model->user->password_reset_token]);
                 } else {
                     $session->setFlash('resetErr', '操作失敗,請稍後再試!');
                 }
             }
         } else {
             $session->setFlash('resetAgain', '對不起,請您重新開始一次。');
             return $this->redirect(['request-password-reset', 'type' => $type]);
         }
     } elseif ($type === 'email') {
         $model = new PasswordResetRequestForm();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             if ($model->sendEmail()) {
                 Yii::$app->getSession()->setFlash('emailSent', '我們已經為您發送了一條鏈接,請進入郵箱查看。');
                 return $this->refresh();
             } else {
                 Yii::$app->getSession()->setFlash('emailFailure', '對不起,我們無法對您的賬戶進行重置密碼操作。');
             }
         }
     } else {
         throw new BadRequestHttpException('參數錯誤!');
     }
     return $this->render('requestPasswordResetToken', ['model' => $model, 'type' => $type, 'step' => $step]);
 }
開發者ID:daixianceng,項目名稱:xiaoego.com,代碼行數:51,代碼來源:SiteController.php

示例10: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     $model->email = Yii::$app->user->identity->email;
     $model->password = Yii::$app->security->generateRandomString(6);
     if ($model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', 'Check your email for new password.');
             return $this->redirect(["site/user"]);
         } else {
             Yii::$app->session->setFlash('error', 'Sorry, we are unable to set up new password for email provided.');
             return $this->redirect(["site/user"]);
         }
     }
 }
開發者ID:bolom009,項目名稱:testwork_vdo,代碼行數:20,代碼來源:SiteController.php

示例11: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', Lang::t('page/siteLogin', 'reset1Success'));
             return $this->goHome();
         } else {
             Yii::$app->session->setFlash('error', Lang::t('page/siteLogin', 'reset1Error'));
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:IVsevolod,項目名稱:zouk,代碼行數:18,代碼來源:SiteController.php

示例12: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $this->view->registerCssFile('/css/shortPage.css');
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', 'Проверьте почиовый ящик и следуйте инструкциям.');
             return $this->goHome();
         } else {
             Yii::$app->session->setFlash('error', 'Извините, мы не смогли отправить Вам письмо с новым паролем.');
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:hunterex68,項目名稱:code,代碼行數:19,代碼來源:SiteController.php

示例13: actionRequestPasswordReset

 public function actionRequestPasswordReset()
 {
     if (!Yii::$app->request->isAjax) {
         return $this->goHome();
     }
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             $erros = ActiveForm::validate($model);
             if (!empty($erros)) {
                 return $erros;
             }
             if (!Yii::$app->request->post('send')) {
                 return $erros;
             }
             if (!$model->sendEmail()) {
                 $erros = [Html::getInputId($model, 'email') => [0 => "Не удалось отправить письмо."]];
                 return $erros;
             } else {
                 Yii::$app->response->statusText = 'send=' . Url::toRoute(['site/request-password-reset-notify']);
                 Yii::$app->response->send();
             }
         }
     }
     return $this->renderAjax('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:an2riy,項目名稱:purina,代碼行數:27,代碼來源:SiteController.php

示例14: actionRequestPasswordReset

 /**
  * Requests password reset.
  *
  * @return mixed
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', I18n::t('Your password reset request submitted successfully'));
             return $this->goHome();
         } else {
             Yii::$app->session->setFlash('error', I18n::t('Unable to reset password for email provided') . '. ' . I18n::t('Please try again'));
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:quyettvq,項目名稱:luspel,代碼行數:18,代碼來源:SiteController.php

示例15: actionRequestPasswordReset

 public function actionRequestPasswordReset()
 {
     $this->layout = 'login';
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Проверьте вашу электронную почту для получения дальнейших инструкций.'));
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', Yii::t('app', 'К сожалению, мы не в состоянии сбросить пароль. Пожалуйста попробуйте позже... Если проблема будет повторятся, обратитесь в службу поддержки.'));
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
開發者ID:shapik2004,項目名稱:album2,代碼行數:14,代碼來源:UserController.php


注:本文中的frontend\models\PasswordResetRequestForm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。