Exemplo n.º 1
2
 public function sendNewPassword(CanResetPassword $user)
 {
     $password = str_random(8);
     $user->password = $password;
     $user->save();
     $this->mailer->send('auth::emails.new_password', compact('user', 'password'), function ($m) use($user) {
         $m->to($user->getEmailForPasswordReset());
     });
 }
Exemplo n.º 2
0
 /**
  * Generate a token for password change and saves it in
  * the Reminder table with the email of the
  * user.
  *
  * @param CanResetPasswordContract $account An existent user.
  *
  * @return string Password reset token.
  */
 public function requestChangePassword(CanResetPasswordContract $account)
 {
     $token = $this->generateToken();
     $values = ['email' => $account->getEmailForPasswordReset(), 'token' => $token, 'created_at' => new \DateTime()];
     $reminder = $this->getReminder()->fill($values);
     $reminder->save();
     $this->sendEmail($account, $token);
     return $token;
 }
 /**
  * Send the password reset link via e-mail.
  * Overrides to use the mail queue.
  *
  * @override
  * @see PasswordBroker::emailResetLink()
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
  * @param  string  $token
  * @param  \Closure|null  $callback
  * @return int
  */
 public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
 {
     // We will use the reminder view that was given to the broker to display the
     // password reminder e-mail. We'll pass a "token" variable into the views
     // so that it may be displayed for an user to click for password reset.
     $view = $this->emailView;
     return $this->mailer->queue($view, compact('token', 'user'), function ($m) use($user, $token, $callback) {
         $m->to($user->getEmailForPasswordReset());
         if (!is_null($callback)) {
             call_user_func($callback, $m, $user, $token);
         }
     });
 }
 /**
  * Determine if a token record exists and is valid.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
  * @param  string  $token
  * @return bool
  */
 public function exists(CanResetPasswordContract $user, $token)
 {
     $email = $user->getEmailForPasswordReset();
     $token = (array) $this->getTable()->where('email', $email)->where('token', $token)->first();
     return $token && !$this->tokenExpired($token);
 }
Exemplo n.º 5
0
 /**
  * Determine if a reminder record exists and is valid.
  *
  * @param \Illuminate\Contracts\Auth\CanResetPassword $user
  * @param string                                      $token
  *
  * @return bool
  */
 public function exists(CanResetPassword $user, $token)
 {
     $email = $user->getEmailForPasswordReset();
     $reminder = $this->makeSelect()->where('o.email = :email')->andWhere('o.token = :token')->setParameter('email', $email)->setParameter('token', $token)->getQuery()->getOneOrNullResult();
     return $reminder != null && !$this->reminderExpired($reminder);
 }
 /**
  * Send the password reset link via e-mail.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword $user
  * @param  string $token
  * @param  \stdClass $viewData
  * @param  \Closure|null $callback
  *
  * @return int
  */
 private function createEmailResetLink(CanResetPasswordContract $user, $token, \stdClass $viewData, Closure $callback = null)
 {
     // We will use the reminder view that was given to the broker to display the
     // password reminder e-mail. We'll pass a "token" variable into the views
     // so that it may be displayed for an user to click for password reset.
     $email = $viewData;
     $email->token = $token;
     $this->mailer->send($this->emailView, compact('email'), function ($m) use($user, $token, $callback) {
         /**
          * @var \Illuminate\Mail\Message $m
          */
         $m->to($user->getEmailForPasswordReset());
         if (!is_null($callback)) {
             call_user_func($callback, $m, $user, $token);
         }
     });
 }
 /**
  * Create a new token for the user.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
  * @return string
  */
 public function createNewToken(CanResetPasswordContract $user)
 {
     $email = $user->getEmailForPasswordReset();
     $value = str_shuffle(sha1($email . spl_object_hash($this) . microtime(true)));
     return hash_hmac('sha1', $value, $this->hashKey);
 }
Exemplo n.º 8
0
 /**
  * Send the password reset link via e-mail.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword $user
  * @param  string $token
  * @param  \Closure|null $callback
  * @return int
  */
 public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
 {
     // We will use the reminder view that was given to the broker to display the
     // password reminder e-mail. We'll pass a "token" variable into the views
     // so that it may be displayed for an user to click for password reset.
     $view = $this->emailView;
     try {
         $this->mailer->send($view, compact('token', 'user'), function ($message) use($user, $token, $callback) {
             $message->from($user->getEmailForPasswordReset());
             $message->to($user->getEmailForPasswordReset());
             if (!is_null($callback)) {
                 call_user_func($callback, $message, $user, $token);
             }
         });
         return Redirect('/')->with('mensaje', 'Se ha enviado el link de cambio de contraseña a tu correo electrónico.');
     } catch (\Exception $ex) {
         switch ($ex->getCode()) {
             case 550:
                 break;
             default:
                 return Redirect('/')->with('mensaje', 'El servidor de correos no ha realizado el envío del link del cambio de contraseña.');
         }
     }
 }