Horde_Registry::setAuth PHP Method

setAuth() public method

If a user name hook was defined in the configuration, it gets applied to the $userId at this point.
public setAuth ( string $authId, array $credentials, array $options = [] )
$authId string The userId that has been authorized.
$credentials array The credentials of the user.
$options array Additional options: - app: (string) The app to set authentication credentials for. DEFAULT: 'horde' - change: (boolean) Whether to request that the user change their password. DEFAULT: No - language: (string) The preferred language. DEFAULT: null - no_convert: (boolean) Don't convert the user name with the authusername hook. DEFAULT: false
    public function setAuth($authId, $credentials, array $options = array())
    {
        global $browser, $injector, $session;
        $app = empty($options['app']) ? 'horde' : $options['app'];
        if ($this->getAuth() == $authId) {
            /* Store app credentials - base Horde session already exists. */
            $this->setAuthCredential($credentials, null, $app);
            return;
        }
        /* Initial authentication to Horde. */
        $session->set('horde', 'auth/authId', $authId);
        $session->set('horde', 'auth/browser', $browser->getAgentString());
        if (!empty($options['change'])) {
            $session->set('horde', 'auth/change', 1);
        }
        $session->set('horde', 'auth/credentials', $app);
        $remote = $this->remoteHost();
        $session->set('horde', 'auth/remoteAddr', $remote->addr);
        $session->set('horde', 'auth/timestamp', time());
        $username = trim($authId);
        if (!empty($GLOBALS['conf']['auth']['lowercase'])) {
            $username = Horde_String::lower($username);
        }
        if (empty($options['no_convert'])) {
            $username = $this->convertUsername($username, true);
        }
        $session->set('horde', 'auth/userId', $username);
        $this->_cache['auth'] = null;
        $this->_cache['existing'] = $this->_cache['isauth'] = array();
        $this->setAuthCredential($credentials, null, $app);
        /* Reload preferences for the new user. */
        unset($GLOBALS['prefs']);
        $this->loadPrefs($this->getApp());
        $this->setLanguageEnvironment(isset($options['language']) ? $this->preferredLang($options['language']) : null, $app);
    }