Example #1
0
 public function actionPasswordResetRequest()
 {
     $model = new PasswordResetRequestForm($this->module->passwordResetTokenExpire);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', Module::t('module', 'FLASH_PASSWORD_RESET_REQUEST'));
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', Module::t('module', 'FLASH_PASSWORD_RESET_ERROR'));
         }
     }
     return $this->render('passwordResetRequest', ['model' => $model]);
 }
 public function testSendEmailCorrectUser()
 {
     $model = new PasswordResetRequestForm(3600);
     $model->email = $this->users[0]['email'];
     /** @var User $user */
     $user = User::findOne(['password_reset_token' => $this->users[0]['password_reset_token']]);
     expect('email sent', $model->sendEmail())->true();
     expect('user has valid token', $user->password_reset_token)->notNull();
     expect('message file exists', file_exists($this->getMessageFile()))->true();
     $message = file_get_contents($this->getMessageFile());
     expect('message file "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
     expect('message file "to" is correct', $message)->contains($model->email);
 }