Horde_Registry::setAuthCredential PHP Method

setAuthCredential() public method

Sets the requested credential for the currently logged in user.
public setAuthCredential ( mixed $credential, string $value = null, string $app = null )
$credential mixed The credential to set. If an array, overwrites the current credentials array.
$value string The value to set the credential to. If $credential is an array, this value is ignored.
$app string The app to update. Defaults to Horde.
    public function setAuthCredential($credential, $value = null, $app = null)
    {
        global $session;
        if (!$this->getAuth()) {
            return;
        }
        if (is_array($credential)) {
            $credentials = $credential;
        } else {
            if (($credentials = $this->_getAuthCredentials($app)) === false) {
                return;
            }
            if (!is_array($credentials)) {
                $credentials = array();
            }
            $credentials[$credential] = $value;
        }
        $entry = $credentials;
        if (($base_app = $session->get('horde', 'auth/credentials')) && $session->get('horde', 'auth_app/' . $base_app) == $entry) {
            $entry = true;
        }
        if (is_null($app)) {
            $app = $base_app;
        }
        /* The auth_app key contains application-specific authentication.
         * Session subkeys are the app names, values are an array containing
         * credentials. If the value is true, application does not require any
         * specific credentials. */
        $session->set('horde', 'auth_app/' . $app, $entry, $session::ENCRYPT);
        $session->set('horde', 'auth_app_init/' . $app, true);
        unset($this->_cache['existing'][$app], $this->_cache['isauth'][$app]);
    }