/**
  * Generate a token for password change and saves it in
  * the 'password_reminders' table with the email of the
  * user.
  *
  * @param RemindableInterface $user An existent user.
  *
  * @return string Password reset token.
  */
 public function requestChangePassword(RemindableInterface $user)
 {
     $email = $user->getReminderEmail();
     $token = $this->generateToken();
     $values = array('email' => $email, 'token' => $token, 'created_at' => new \DateTime());
     $this->app['db']->connection($user->getConnectionName())->table('password_reminders')->insert($values);
     $this->sendEmail($user, $token);
     return $token;
 }
 /**
  * Send the password reminder e-mail.
  *
  * @param  \Illuminate\Auth\Reminders\RemindableInterface  $user
  * @param  string   $token
  * @param  Closure  $callback
  * @return void
  */
 public function sendReminder(RemindableInterface $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->reminderView;
     $type = $this->type;
     return $this->mailer->send($view, compact('token', 'user', 'type'), function ($m) use($user, $token, $type, $callback) {
         $m->to($user->getReminderEmail());
         if (!is_null($callback)) {
             call_user_func($callback, $m, $user, $type, $token);
         }
     });
 }
 /**
  * Create a new token for the user.
  *
  * @param  \Illuminate\Auth\Reminders\RemindableInterface  $user
  * @return string
  */
 public function createNewToken(RemindableInterface $user)
 {
     $email = $user->getReminderEmail();
     $value = str_shuffle(sha1($email . spl_object_hash($this) . microtime(true)));
     return hash_hmac('sha1', $value, $this->hashKey);
 }
 /**
  * Sends an email containing the reset password link with the
  * given token to the user.
  *
  * @param RemindableInterface $user  An existent user.
  * @param string              $token Password reset token.
  *
  * @return void
  */
 protected function sendEmail($user, $token)
 {
     $config = $this->app['config'];
     $lang = $this->app['translator'];
     $this->app['mailer']->queueOn($config->get('confide::email_queue'), $config->get('confide::email_reset_password'), compact('user', 'token'), function ($message) use($user, $token, $lang) {
         $message->to($user->getEmail(), $user->getUsername())->subject($lang->get('confide::confide.email.password_reset.subject'));
     });
 }