Login using the cached admin user token.

@param string $token

@return \Illuminate\Http\RedirectResponse
@throws \Exception
@throws \Psr\SimpleCache\InvalidArgumentException
324448
public function checkLoginToken(string $token)
    {

        if ($token != cache('admin_login_token'))
            abort(404);

        $user = User::whereName('admin')->first();

        if (is_null($user))
            return redirect()->route('auth.login')
                ->withErrors('The Admin user does not exist. Re-run the seat:admin:login command.');

        // Login and clear the token we just used.
        auth()->login($user);
        cache()->delete('admin_login_token');

        return redirect()->intended('home');

    }
798550
public function userByResetPasswordToken($token)
    {
        if($email = app('account.password')->getEmailByToken($token)){

            return $this->findByEmail($email);
        }

        return false;
    }
750676
public function expireByToken($token)
    {
        $token = $this->findByToken($token);

        if (! is_null($token)) {
            return $token->expire();
        }
    }
752607
public function loginViaToken($token)
    {
        global $wpdb, $wp_hasher;

        $key = preg_replace('/[^a-z0-9]/i', '', $token);

        if (empty($key) || !is_string($key)) {
            throw new MoufpressException('Invalid token: '.$token);
        }

        $row = $wpdb->get_row($wpdb->prepare("SELECT user_login FROM $wpdb->users WHERE user_activation_key = %s", $token));
        if (!$row) {
            throw new MoufpressException('Invalid token: '.$token);
        }
        $this->loginWithoutPassword($row->user_login);
    }
116269
public function authenticate(TokenInterface $token)
    {
        if (!$token instanceof GuardTokenInterface) {
            throw new \InvalidArgumentException('GuardAuthenticationProvider only supports GuardTokenInterface.');
        }

        if (!$token instanceof PreAuthenticationGuardToken) {
            /*
             * The listener *only* passes PreAuthenticationGuardToken instances.
             * This means that an authenticated token (e.g. PostAuthenticationGuardToken)
             * is being passed here, which happens if that token becomes
             * "not authenticated" (e.g. happens if the user changes between
             * requests). In this case, the user should be logged out, so
             * we will return an AnonymousToken to accomplish that.
             */

            // this should never happen - but technically, the token is
            // authenticated... so it could just be returned
            if ($token->isAuthenticated()) {
                return $token;
            }

            // this AccountStatusException causes the user to be logged out
            throw new AuthenticationExpiredException();
        }

        $guardAuthenticator = $this->findOriginatingAuthenticator($token);

        if (null === $guardAuthenticator) {
            throw new AuthenticationException(sprintf('Token with provider key "%s" did not originate from any of the guard authenticators of provider "%s".', $token->getGuardProviderKey(), $this->providerKey));
        }

        return $this->authenticateViaGuard($guardAuthenticator, $token);
    }
858968
public function get($token)
    {
        foreach (
            $this->getEntityManager()->getConnection()->fetchAll(
                'SELECT * FROM oauth_access_token WHERE access_token=:token',
                ['token' => $token]
            ) as $row
        ) {
            return (new AccessTokenEntity($this->server))
                ->setId($row['access_token'])
                ->setExpireTime($row['expire_time']);
        };
        return null;
    }
80287
public function invalidate_sessions($token = '')
    {
        if (!$this->token->validate('invalidate_sessions', $token)) {
            $this->error->add($this->token->getErrorMessage());

            $this->flash('error', $this->error);

            // Redirect away from this save endpoint
            return $this->factory->redirect($this->action());
        }

        // Invalidate all sessions
        $this->invalidateSessions();

        // Set a message for the login page
        $this->flash('error', t('All sessions have been invalidated. You must log back in to continue.'));

        // Redirect to the login page
        return $this->factory->redirect($this->urls->resolve(['/login']));
    }
564287
public function setPasswordResetToken($token = '')
    {
        if (empty($this->passwordResetTokenAttribute) || !is_string($this->passwordResetTokenAttribute)) {
            return null;
        }
        return $this->{$this->passwordResetTokenAttribute} = $token;
    }
763838
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        // get url to redirect (or return in the JSON-response)
        if ($this->session->get('_security.admin.target_path')
            && false !== strpos($this->session->get('_security.admin.target_path'), '#')
        ) {
            $url = $this->session->get('_security.admin.target_path');
        } else {
            $url = $this->router->generate('sulu_admin');
        }

        if ($request->isXmlHttpRequest()) {
            // if AJAX login
            $array = ['url' => $url];
            $response = new JsonResponse($array, 200);
        } else {
            // if form login
            $response = new RedirectResponse($url);
        }

        return $response;
    }
1126704
public function authenticate($token, $authMethod = null)
    {
        if ($token === null) {
            throw InvalidArgumentException('You need to specify a token');
        }

        if ($authMethod === null) {
            $authMethod = self::AUTH_URL_TOKEN;
        }

        $this->getHttpClient()->authenticate($token, $authMethod);
    }
29577
public function findUserByToken($token)
    {
        $qb = $this->createQueryBuilder('user')
            ->where('user.passwordResetToken=:token');

        $query = $qb->getQuery();
        $query->setParameter('token', $token);

        return $query->getSingleResult();
    }
225684
public function getByAccessToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('access_token', '=', $token)->first());
	}
1368021
public function actionResetPassword($token)
    {
        try {
            $model = new ResetPasswordForm($token);
        } catch (InvalidParamException $e) {
            throw new BadRequestHttpException($e->getMessage());
        }

        if ($model->load(Yii::$app->getRequest()->post()) && $model->validate() && $model->resetPassword()) {
            Yii::$app->getSession()->setFlash('success', yii::t('cms', 'New password was saved.'));

            return $this->goHome();
        }

        return $this->render('resetPassword', [
            'model' => $model,
        ]);
    }
365337
protected function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();
        if (!$user instanceof UserInterface) {
            return $token;
        }

        $userNotFoundByProvider = false;
        $userDeauthenticated = false;

        foreach ($this->userProviders as $provider) {
            if (!$provider instanceof UserProviderInterface) {
                throw new \InvalidArgumentException(sprintf('User provider "%s" must implement "%s".', \get_class($provider), UserProviderInterface::class));
            }

            try {
                $refreshedUser = $provider->refreshUser($user);
                $newToken = clone $token;
                $newToken->setUser($refreshedUser);

                // tokens can be deauthenticated if the user has been changed.
                if (!$newToken->isAuthenticated()) {
                    $userDeauthenticated = true;

                    if (null !== $this->logger) {
                        $this->logger->debug('Cannot refresh token because user has changed.', ['username' => $refreshedUser->getUsername(), 'provider' => \get_class($provider)]);
                    }

                    continue;
                }

                $token->setUser($refreshedUser);

                if (null !== $this->logger) {
                    $context = ['provider' => \get_class($provider), 'username' => $refreshedUser->getUsername()];

                    if ($token instanceof SwitchUserToken) {
                        $context['impersonator_username'] = $token->getOriginalToken()->getUsername();
                    } else {
                        foreach ($token->getRoles(false) as $role) {
                            if ($role instanceof SwitchUserRole) {
                                $context['impersonator_username'] = $role->getSource(false)->getUsername();
                                break;
                            }
                        }
                    }

                    $this->logger->debug('User was reloaded from a user provider.', $context);
                }

                return $token;
            } catch (UnsupportedUserException $e) {
                // let's try the next user provider
            } catch (UsernameNotFoundException $e) {
                if (null !== $this->logger) {
                    $this->logger->warning('Username could not be found in the selected user provider.', ['username' => $e->getUsername(), 'provider' => \get_class($provider)]);
                }

                $userNotFoundByProvider = true;
            }
        }

        if ($userDeauthenticated) {
            if (null !== $this->logger) {
                $this->logger->debug('Token was deauthenticated after trying to refresh it.');
            }

            if (null !== $this->dispatcher) {
                $this->dispatcher->dispatch(new DeauthenticatedEvent($token, $newToken), DeauthenticatedEvent::class);
            }

            return null;
        }

        if ($userNotFoundByProvider) {
            return null;
        }

        throw new \RuntimeException(sprintf('There is no user provider for user "%s".', \get_class($user)));
    }
84476
public function get($token)
    {
        $result = $this->getConnection()->table('oauth_refresh_tokens')
                ->where('oauth_refresh_tokens.id', $token)
                ->where('oauth_refresh_tokens.expire_time', '>=', time())
                ->first();

        if (is_null($result)) {
            return;
        }

        return (new RefreshTokenEntity($this->getServer()))
               ->setId($result->id)
               ->setAccessTokenId($result->access_token_id)
               ->setExpireTime((int) $result->expire_time);
    }
506182
public function authenticate($token = false)
    {
        $id = $this->getPayload($token)->get('sub');
        if (! $this->auth->byId($id)) {
            return false;
        }

        return $this->auth->user();
    }
187212
public function invalidateToken(Token $token)
    {
        $this->tokenCache->remove($token->getHash());

        $this->logger->log(sprintf('Deleted token %s.', $token->getIdentifier()), LOG_INFO);
    }