protected function checkSessionDatabase($authCookie)
    {
        $userIp = $this->cookieOptions['remoteaddr'] ? $this->getClientIp() : null;
        $userAgent = $this->cookieOptions['browseragent'] ? $this->getClientUserAgent() : null;

        try {
            if (!$authTokenEntity = $this->getRepositoryAuthtoken()->getToken($authCookie, $userIp, $userAgent)) {
                return false;
            }

            if (!$databaseUser = $this->getRepositoryUsers()->getUser($authTokenEntity->getUserId())) {
                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);
    }