Bolt\AccessControl\AccessChecker::checkSessionDatabase PHP Method

checkSessionDatabase() protected method

Check the user authentication cookie against what is stored in the database.
protected checkSessionDatabase ( string $authCookie ) : boolean
$authCookie string
return boolean
    protected function checkSessionDatabase($authCookie)
    {
        $userAgent = $this->cookieOptions['browseragent'] ? $this->getClientUserAgent() : null;
        try {
            if (!($authTokenEntity = $this->getRepositoryAuthtoken()->getToken($authCookie, $this->getClientIp(), $userAgent))) {
                return false;
            }
            if (!($databaseUser = $this->getRepositoryUsers()->getUser($authTokenEntity->getUsername()))) {
                return false;
            }
        } catch (TableNotFoundException $e) {
            return false;
        }
        // Update session data
        $sessionAuth = new Token\Token($databaseUser, $authTokenEntity);
        $this->session->set('authentication', $sessionAuth);
        // Check if user is _still_ allowed to log on.
        if (!$this->permissions->isAllowed('login', $sessionAuth->getUser()->toArray(), null) || !$sessionAuth->isEnabled()) {
            $this->systemLogger->error('User ' . $sessionAuth->getUser()->getUsername() . ' has been disabled and can not login.', ['event' => 'authentication']);
            return false;
        }
        return $this->checkSessionKeys($sessionAuth);
    }