Ejemplo n.º 1
0
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('alert', ['body' => Yii::t('frontend', 'Check your email for further instructions.'), 'options' => ['class' => 'alert-success']]);
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('alert', ['body' => Yii::t('frontend', 'Sorry, we are unable to reset password for email provided.'), 'options' => ['class' => 'alert-danger']]);
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
Ejemplo n.º 2
0
 /**
  * Renders the index view for the module
  * @return string
  */
 public function actionIndex()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
         } else {
             Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
         }
         return $this->redirect('/user/forgotpassword');
     }
     return $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 3
0
 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);
     });
 }
Ejemplo n.º 4
0
 /**
  * Request for password recovery
  *
  * @return string|\yii\web\Response
  */
 public function actionRequestPasswordReset()
 {
     $model = new PasswordResetRequestForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', Module::t('password', 'MESSAGE_SUCCESS_REQUEST_PASSWORD'));
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', Module::t('password', 'MESSAGE_ERROR_REQUEST_PASSWORD'));
         }
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }