Horde_Registry::checkExistingAuth PHP Method

checkExistingAuth() public method

Check existing auth for triggers that might invalidate it.
public checkExistingAuth ( string $app = 'horde' ) : boolean
$app string Check authentication for this app too.
return boolean Is existing auth valid?
    public function checkExistingAuth($app = 'horde')
    {
        global $browser, $conf, $injector, $session;
        if (!empty($this->_cache['existing'][$app])) {
            return true;
        }
        /* Tasks that only need to run once. */
        if (empty($this->_cache['existing'])) {
            if (!empty($conf['auth']['checkip']) && ($remoteaddr = $session->get('horde', 'auth/remoteAddr')) && ($remoteob = $this->remoteHost()) && $remoteaddr != $remoteob->addr) {
                $injector->getInstance('Horde_Core_Factory_Auth')->create()->setError(Horde_Core_Auth_Application::REASON_SESSIONIP);
                return false;
            }
            if (!empty($conf['auth']['checkbrowser']) && $session->get('horde', 'auth/browser') != $browser->getAgentString()) {
                $injector->getInstance('Horde_Core_Factory_Auth')->create()->setError(Horde_Core_Auth_Application::REASON_BROWSER);
                return false;
            }
            if (!empty($conf['session']['max_time']) && $conf['session']['max_time'] + $session->begin < time()) {
                $injector->getInstance('Horde_Core_Factory_Auth')->create()->setError(Horde_Core_Auth_Application::REASON_SESSIONMAXTIME);
                return false;
            }
        }
        foreach (array_unique(array('horde', $app)) as $val) {
            if (!isset($this->_cache['existing'][$val])) {
                $auth = $injector->getInstance('Horde_Core_Factory_Auth')->create($val);
                if (!$auth->validateAuth()) {
                    if (!$auth->getError()) {
                        $auth->setError(Horde_Auth::REASON_SESSION);
                    }
                    return false;
                }
                $this->_cache['existing'][$val] = true;
            }
        }
        return true;
    }