src/Charcoal/User/Authenticator.php
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;
        }
    }
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;
        }
    }
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 ; } }
Attempt to authenticate a user using their auth token.

@return \Charcoal\User\UserInterface|null Returns the authenticated user object
or NULL if not authenticated.
Attempt to authenticate a user using their auth token .