protected function authenticateUser()
    {
        if (\System::getContainer()->get('cca.dc-general.scope-matcher')->currentScopeIsUnknown()) {
            return false;
        }

        // Do not execute anything if we are on the login page because no User is logged in.
        if (strpos(Environment::get('script'), 'contao/login') !== false) {
            return false;
        }

        // Issue #66 - contao/install.php is not working anymore. Thanks to Stefan Lindecke (@lindesbs).
        if (strpos(Environment::get('request'), 'install') !== false) {
            return false;
        }

        if (strpos(Environment::get('script'), 'system/bin') !== false) {
            return false;
        }

        // Bug fix: If the user is not authenticated, contao will redirect to contao/index.php
        // But in this moment the TL_PATH is not defined, so the $this->Environment->request
        // generate a url without replacing the basepath(TL_PATH) with an empty string.
        $authResult = $this->getUser()->authenticate();

        return ($authResult === true || $authResult === null) ? true : false;
    }