Пример #1
0
 /**
  * Looks up a user from a given forgot token.
  *
  * @param string $token
  *
  * @throws AuthException when the token is invalid.
  *
  * @return \Infuse\Auth\Interfaces\UserInterface
  */
 public function getUserFromToken($token)
 {
     $expiration = U::unixToDb(time() - UserLink::$forgotLinkTimeframe);
     $link = UserLink::where('link', $token)->where('type', UserLink::FORGOT_PASSWORD)->where('created_at', $expiration, '>')->first();
     if (!$link) {
         throw new AuthException('This link has expired or is invalid.');
     }
     $userClass = $this->auth->getUserClass();
     return new $userClass($link->user_id);
 }
Пример #2
0
 /**
  * Processes a verify email hash.
  *
  * @param string $token verification hash
  *
  * @return UserInterface|false
  */
 public function verifyEmailWithToken($token)
 {
     $link = UserLink::where('link', $token)->where('type', UserLink::VERIFY_EMAIL)->first();
     if (!$link) {
         return false;
     }
     $userClass = $this->getUserClass();
     $user = new $userClass($link->user_id);
     // enable the user and delete the verify link
     $user->enable();
     $link->delete();
     // send a welcome email
     $user->sendEmail('welcome');
     return $user;
 }