/** * Log out the current user. * Also disables autologin for this session. */ function user_logout() { User::logout(db()); }
$logout = require_post("logout", require_get("logout", false)); $openid = $use_password ? false : require_post("openid", require_get("openid", require_post("openid_manual", require_get("openid_manual", false)))); $oauth2 = require_post("oauth2", require_get("oauth2", false)); if ($openid && !is_string($openid)) { throw new Exception(t("Invalid openid parameter")); } $messages = array(); $errors = array(); // try logging in? try { if ($openid && $password) { // but you can add OpenID identities later throw new EscapedException(t("You cannot use both OpenID and password at login.")); } if ($logout) { User::logout(db()); $messages[] = t("Successfully logged out. You may login again here."); } else { if (!require_get("pause", false)) { $user = false; try { if ($oauth2) { $args = array('oauth2' => $oauth2); $url = absolute_url(url_for('login', $args)); $provider = Users\OAuth2Providers::createProvider($oauth2, $url); $user = Users\UserOAuth2::tryLogin(db(), $provider, $url); } else { if ($openid) { // we want to add the openid identity URL to the return address // (the return URL is also verified in validate()) $args = array("openid" => $openid);