Check if auth token is present, if true, try to load the right user and return it's username.

@return bool|AbstractUser False it user token is not available, otherwise the AbstractUser object is returned.
433832
public function loadUserFromToken()
    {
        $token = $this->httpSession()->get($this->getTokenName());
        if (!$token) {
            return false;
        }

        return $this->decryptUserData($token);
    }
116174
public function getAuthenticatedUser()
    {
        $user = $this->getStorage()
                     ->getAuthenticatedUser($this->request, $this->response);

        if ($user) {
            // check if the user needs 2FA verification
            $twoFactor = $this->getTwoFactorStrategy();
            if ($twoFactor && !$user->isTwoFactorVerified() && $twoFactor->needsVerification($user)) {
                $user->markSignedOut();
            }

            $this->setCurrentUser($user);
        } else {
            // if no current user then sign in a guest
            $user = $this->signInUser($this->getGuestUser());
        }

        return $user;
    }
812634
protected function getUserId() {
        $user = Auth::user();
        if (is_object($user) && !empty($user->id)) {
            return $user->id;
        } else {
            return null;
        }
    }
374767
public function user()
    {
        /*
         * If we have already retrieved the user for the current request we can
         * just return it back immediately.
         */
        if (! is_null($this->user)) {
            return $this->user;
        }

        // Attempt to retrieve the token from the request
        $token = $this->jwt->getToken();
        if (! $token) {
            return null;
        }

        // Get the user associated with the token
        try {
            $user = $this->jwt->toUser($token);
        } catch (JWTException $e) {
            return null;
        }

        return $this->user = $user;
    }
1147027
public function getUser()
    {
        /** @var AbstractAdmin $admin */
        $admin = $this;

        $container = $admin->getContainer();

        if (!$container->has('security.token_storage')) {
            return null;
        }

        $tokenStorage = $container->get('security.token_storage');

        if (null === $token = $tokenStorage->getToken()) {
            return null;
        }

        if (!\is_object($user = $token->getUser())) {
            // e.g. anonymous authentication
            return null;
        }

        return $user;
    }
1114764
private function authenticateByToken()
    {
        $tokenType = $this->tokenType();
        $authToken = $this->tokenFactory()->create($tokenType);

        if ($authToken->metadata()->enabled() !== true) {
            return null;
        }

        $tokenData = $authToken->getTokenDataFromCookie();
        if (!$tokenData) {
            return null;
        }
        $userId = $authToken->getUserIdFromToken($tokenData['ident'], $tokenData['token']);
        if (!$userId) {
            return null;
        }

        $u = $this->userFactory()->create($this->userType());
        $u->load($userId);

        if ($u->id()) {
            $u->saveToSession();
            return $u;
        } else {
            return null;
        }
    }
704039
protected function getUserByToken()
    {
        // Look up in cache and return if found
        if ($user = cache_get('api.masterToken', $this->getCacheParams())) {
            return $user;
        }

        $user = $this->getUserModel()->where(
            $this->getTokenColumn('column'),
            $this->getTokenColumn('operator'),
            $this->getTokenColumn('value')
        )
                     ->first();

        // Add to cache
        cache_put('api.masterToken', $this->getCacheParams(), $user);

        return $user;
    }
74964
public function getToken()
    {
        if (!$this->token) {
            $session = new Session('Auth');
            if (!$session->token) {
                $session->token = uniqid();
            }
            $this->token = $session->token;
        }
        return $this->token;
    }
143909
public function user()
    {
        if ($this->user !== null) {
            return $this->user;
        }

        if ($this->jwT->setRequest($this->request)->getToken() &&
            ($payload = $this->jwT->check(true)) &&
            $this->jwT->checkProvider($this->provider->getModel())
        ) {
            return $this->user = $this->provider->retrieveById($payload['sub']);
        }
    }
882667
protected function getUserId()
    {
        try {
            if (Auth::check()) {
                return Auth::user()->getAuthIdentifier();
            }
        } catch (Exception $e) {
            Log::emergency($e);
            return;
        }

        return;
    }
769606
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        return $this->user = call_user_func($this->callback, $this->request);
    }
531269
public function getAuthenticatedUser ()
    {
        $curUserEntity = $this->ServiceContainer->get('security.context')->getToken()->getUser();
        if (!is_object($curUserEntity)) {
            throw new Exception("No authenticated user found");
        }

        $CurUser = $this->getModelRepository('User')->getById($curUserEntity->getId());
        return $CurUser;
    }
795065
public function getUser()
    {
        if (! $this->_user) {
            $request = $this->getRequest();

            $this->_user = $this->loader->getUser($request->getParam($this->usernameFieldName), $request->getParam($this->organizationFieldName));
        }
        return $this->_user;
    }
1245283
public function getUserId() {
    if (array_key_exists(self::USER_ATTR, $this->payload)) {
      return $this->payload[self::USER_ATTR];
    }
    throw new AuthException("No user_id in token");
  }
452548
public function getUser()
    {
        if ( ! $this->container->has('security')) {
            return false;
        }

        $security = $this->container->get('security');

        if ( ! $token = $security->getToken()) {
            return false;
        }

        $user = $token->getUser();
        if ( ! $user instanceof UserInterface) {
            return false;
        }

        return $user;
    }
470066
public function getUser()
    {
        if (null === $this->user && $this->isLogin()) {
            $username = Base::instance()->get(static::SESSION_USER);
            $this->user = Security::instance()->getUserProvider()->loadByUsername($username);

            try {
                Authentication::instance()->checkUser($this->user);
            } catch(Exception $e) {
                $this->user = null;
            }
        }

        return $this->user;
    }
39530
public function getToken()
    {
        if (! $this->token) {
            try {
                $this->parseToken();
            } catch (JwTException $e) {
                return false;
            }
        }

        return $this->token;
    }