From a5fdc99fca312c9dd7e9f593bcf9f6e8f843572e Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Aug 2015 16:43:45 -0500 Subject: [PATCH] Additional fix to prevent useless redirection in SSO for Drupal - refs BT#10145 --- index.php | 4 +++- main/inc/lib/userportal.lib.php | 3 ++- main/inc/local.inc.php | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index b6c87ae579..612afc8c3e 100755 --- a/index.php +++ b/index.php @@ -35,9 +35,11 @@ $controller = new IndexManager($header_title); $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed); if (!empty($_GET['logout'])) { - $controller->logout(); + $redirect = !empty($_GET['no_redirect']) ? false : true; + $controller->logout($redirect); } + /* Table definitions */ /* Constants and CONFIGURATION parameters */ diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 476ecaeccc..f723373f5a 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -96,8 +96,9 @@ class IndexManager /** * Alias for the online_logout() function + * @param bool $redirect Whether to ask online_logout to redirect to index.php or not */ - function logout() { + function logout($redirect = true) { online_logout($this->user_id, true); } diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index a9811abbef..1dcfdcda05 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -647,7 +647,13 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) { exit; } } - }//end logout ... else ... login + //end logout ... else ... login + } elseif ($logout) { + //if there was an attempted logout without a previous login, log + // this anonymous user out as well but avoid redirect + online_logout(null, false); + $osso->logout(); //redirects and exits + } } elseif (api_get_setting('openid_authentication')=='true') { if (!empty($_POST['openid_url'])) { include api_get_path(SYS_CODE_PATH).'auth/openid/login.php';