diff --git a/include/baseTheme.php b/include/baseTheme.php index d5ad8bc3b2..5e358ee30c 100644 --- a/include/baseTheme.php +++ b/include/baseTheme.php @@ -262,7 +262,7 @@ function get_theme_class($class) { $t->set_var('LANG_STATS', q($GLOBALS['langMyStats'])); $t->set_var('STATS_LINK', $urlAppend . 'modules/usage/?t=u'); $t->set_var('LANG_LOGOUT', q($langLogout)); - $t->set_var('LOGOUT_LINK', $urlAppend . 'index.php?logout=yes'); + $t->set_var('LOGOUT_LINK', $urlAppend . 'modules/auth/logout.php'); $t->set_var('MY_COURSES', q($GLOBALS['langMyCoursesSide'])); $t->set_var('MY_MESSAGES', q($GLOBALS['langNewMyMessagesSide'])); $t->set_var('LANG_ANNOUNCEMENTS', q($GLOBALS['langMyAnnouncements'])); diff --git a/include/main_lib.php b/include/main_lib.php index 29ea98ebf0..0cc6de3cf4 100644 --- a/include/main_lib.php +++ b/include/main_lib.php @@ -4079,6 +4079,7 @@ function warnCourseInvalidDepartment($prompt=false) { * 'am' - Student id number */ function login_hook($options) { + session_regenerate_id(); if (!isset($options['am'])) { $options['am'] = ''; } diff --git a/index.php b/index.php index ec3413bed5..090d96b5b3 100644 --- a/index.php +++ b/index.php @@ -70,44 +70,21 @@ $uid = 0; } -if (isset($_GET['logout']) and $uid) { - $cas = ($session->getLoginMethod() == 'cas')? get_auth_settings(7): false; - Database::get()->query("INSERT INTO loginout (loginout.id_user, - loginout.ip, loginout.when, loginout.action) - VALUES (?d, ?s, " .DBHelper::timeAfter() . ", 'LOGOUT')", $uid, Log::get_client_ip()); - foreach (array_keys($_SESSION) as $key) { - unset($_SESSION[$key]); - } - - // include HybridAuth libraries - require_once 'modules/auth/methods/hybridauth/config.php'; - - $config = get_hybridauth_config(); - $hybridauth = new Hybridauth\Hybridauth( $config ); - - session_destroy(); - $uid = 0; - if ($cas and isset($cas['cas_ssout']) and intval($cas['cas_ssout']) === 1) { - phpCAS::client(SAML_VERSION_1_1, $cas['cas_host'], intval($cas['cas_port']), $cas['cas_context'], FALSE); - phpCAS::logoutWithRedirectService($urlServer); - } -} - // if we try to login... then authenticate user. $warning = ''; if(isset($_SESSION['hybridauth_callback'])) { - switch($_SESSION['hybridauth_callback']) { - case 'login': - $_GET['provider'] = $_SESSION['hybridauth_provider'] ?? ''; - break; - case 'profile': - $provider = $_SESSION['hybridauth_provider'] ?? ''; - header('Location: /main/profile/profile.php?action=connect&provider='.$provider.'&'.$_SERVER['QUERY_STRING']); - exit; + switch($_SESSION['hybridauth_callback']) { + case 'login': + $_GET['provider'] = $_SESSION['hybridauth_provider'] ?? ''; + break; + case 'profile': + $provider = $_SESSION['hybridauth_provider'] ?? ''; + header('Location: /main/profile/profile.php?action=connect&provider='.$provider.'&'.$_SERVER['QUERY_STRING']); + exit; case 'auth_test': - $provider = $_SESSION['hybridauth_provider'] ?? ''; - header('Location: /modules/admin/auth_test.php?auth='.$provider.'&'.$_SERVER['QUERY_STRING']); + $provider = $_SESSION['hybridauth_provider'] ?? ''; + header('Location: /modules/admin/auth_test.php?auth='.$provider.'&'.$_SERVER['QUERY_STRING']); exit; } } @@ -115,7 +92,7 @@ if (isset($_SESSION['shib_uname'])) { // authenticate via shibboleth shib_cas_login('shibboleth'); -} elseif (isset($_SESSION['cas_uname']) && !isset($_GET['logout'])) { +} elseif (isset($_SESSION['cas_uname'])) { // authenticate via cas shib_cas_login('cas'); } elseif (isset($_GET['provider'])) { @@ -144,7 +121,7 @@ } // check if we are guest user -if (!$upgrade_begin and $uid and !isset($_GET['logout'])) { +if (!$upgrade_begin and $uid) { if (check_guest()) { // if the user is a guest send him straight to the corresponding lesson $guest = Database::get()->querySingle("SELECT code FROM course_user, course diff --git a/main/toolbox.php b/main/toolbox.php index 939e9407ae..e6f18234d3 100644 --- a/main/toolbox.php +++ b/main/toolbox.php @@ -115,7 +115,7 @@ $t->set_var('langSelectFromMenu', js_escape($langSelectFromMenu)); if ($uid) { $t->set_var('loginLogout', q($_SESSION['givenname'] . ' ' . $_SESSION['surname']) . - " $langLogout"); + " $langLogout"); $t->set_block('main', 'loginModalsBlock', 'delete'); } else { $t->set_var('loginModal', 'loginModal'); diff --git a/main/unreguser.php b/main/unreguser.php index e98362726a..110f153aae 100644 --- a/main/unreguser.php +++ b/main/unreguser.php @@ -94,7 +94,7 @@ $tool_content .= action_bar(array( array('title' => $langLogout, - 'url' => "../index.php?logout=yes", + 'url' => $urlAppend . 'modules/auth/logout.php', 'icon' => 'fa-sign-out', 'level' => 'primary-label'))); $tool_content .= "