/**
  * Sends recovery message.
  */
 public function recoverPassword()
 {
     $user = User::findOne(['email' => $this->email]);
     if ($user != NULL) {
         $user->password_reset_token = Yii::$app->getSecurity()->generateRandomString() . '_' . time();
         $user->save(FALSE);
     }
     // Sends recovery mail
     Mailer::sendRecoveryMessage($user);
     Yii::$app->session->setFlash('info', 'You will receive an email with instructions on how to reset your password in a few minutes.');
 }
 /**
  *  Register the user
  *
  * @return string|\yii\web\Response
  */
 public function actionRegister()
 {
     $model = new User();
     $model->scenario = 'register';
     if ($model->load(Yii::$app->request->post()) && $model->register(FALSE, User::STATUS_PENDING)) {
         // Send Welcome Message to activate the account
         Mailer::sendWelcomeMessage($model);
         Yii::$app->session->setFlash('success', Yii::t('user', 'You\'ve successfully been registered. Check your mail to activate your account'));
         return $this->redirect(Yii::$app->urlManager->createUrl('//user/auth/login'));
     }
     return $this->render('register', ['model' => $model]);
 }
Exemplo n.º 3
0
 /**
  * Sends password recovery mail to the user
  *
  * @param \abhimanyu\user\models\User $user
  *
  * @return bool
  */
 public static function sendRecoveryMessage(User $user)
 {
     return Mailer::sendMail($user->email, 'Password Recovery', 'recovery', ['user' => $user]);
 }