コード例 #1
0
 /**
  * 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.');
 }
コード例 #2
0
 /**
  *  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]);
 }
コード例 #3
0
ファイル: Mailer.php プロジェクト: fabristyle/yii2-user-1
 /**
  * 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]);
 }