CAS_Client::_wasPreviouslyAuthenticated PHP Method

_wasPreviouslyAuthenticated() private method

This method tells if the user has already been (previously) authenticated by looking into the session variables.
private _wasPreviouslyAuthenticated ( ) : true
return true when the user has already been authenticated; false otherwise.
    private function _wasPreviouslyAuthenticated()
    {
        phpCAS::traceBegin();
        if ($this->_isCallbackMode()) {
            // Rebroadcast the pgtIou and pgtId to all nodes
            if ($this->_rebroadcast && !isset($_POST['rebroadcast'])) {
                $this->_rebroadcast(self::PGTIOU);
            }
            $this->_callback();
        }
        $auth = false;
        if ($this->isProxy()) {
            // CAS proxy: username and PGT must be present
            if ($this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt'])) {
                // authentication already done
                $this->_setUser($_SESSION['phpCAS']['user']);
                if (isset($_SESSION['phpCAS']['attributes'])) {
                    $this->setAttributes($_SESSION['phpCAS']['attributes']);
                }
                $this->_setPGT($_SESSION['phpCAS']['pgt']);
                phpCAS::trace('user = `' . $_SESSION['phpCAS']['user'] . '\', PGT = `' . $_SESSION['phpCAS']['pgt'] . '\'');
                // Include the list of proxies
                if (isset($_SESSION['phpCAS']['proxies'])) {
                    $this->_setProxies($_SESSION['phpCAS']['proxies']);
                    phpCAS::trace('proxies = "' . implode('", "', $_SESSION['phpCAS']['proxies']) . '"');
                }
                $auth = true;
            } elseif ($this->isSessionAuthenticated() && empty($_SESSION['phpCAS']['pgt'])) {
                // these two variables should be empty or not empty at the same time
                phpCAS::trace('username found (`' . $_SESSION['phpCAS']['user'] . '\') but PGT is empty');
                // unset all tickets to enforce authentication
                unset($_SESSION['phpCAS']);
                $this->setTicket('');
            } elseif (!$this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt'])) {
                // these two variables should be empty or not empty at the same time
                phpCAS::trace('PGT found (`' . $_SESSION['phpCAS']['pgt'] . '\') but username is empty');
                // unset all tickets to enforce authentication
                unset($_SESSION['phpCAS']);
                $this->setTicket('');
            } else {
                phpCAS::trace('neither user nor PGT found');
            }
        } else {
            // `simple' CAS client (not a proxy): username must be present
            if ($this->isSessionAuthenticated()) {
                // authentication already done
                $this->_setUser($_SESSION['phpCAS']['user']);
                if (isset($_SESSION['phpCAS']['attributes'])) {
                    $this->setAttributes($_SESSION['phpCAS']['attributes']);
                }
                phpCAS::trace('user = `' . $_SESSION['phpCAS']['user'] . '\'');
                // Include the list of proxies
                if (isset($_SESSION['phpCAS']['proxies'])) {
                    $this->_setProxies($_SESSION['phpCAS']['proxies']);
                    phpCAS::trace('proxies = "' . implode('", "', $_SESSION['phpCAS']['proxies']) . '"');
                }
                $auth = true;
            } else {
                phpCAS::trace('no user found');
            }
        }
        phpCAS::traceEnd($auth);
        return $auth;
    }
CAS_Client