diff --git a/auth/cas/auth.php b/auth/cas/auth.php index d94c3965ba6..5eb84340d74 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -154,6 +154,7 @@ class auth_plugin_cas extends auth_plugin_ldap { $frm = new stdClass(); $frm->username = phpCAS::getUser(); $frm->password = 'passwdCas'; + $frm->logintoken = \core\session\manager::get_login_token(); // Redirect to a course if multi-auth is activated, authCAS is set to CAS and the courseid is specified. if ($this->config->multiauth && !empty($courseid)) { @@ -167,6 +168,7 @@ class auth_plugin_cas extends auth_plugin_ldap { $frm = new stdClass(); $frm->username = 'guest'; $frm->password = 'guest'; + $frm->logintoken = \core\session\manager::get_login_token(); return; } diff --git a/login/index.php b/login/index.php index d62d7e114d8..a04970acfff 100644 --- a/login/index.php +++ b/login/index.php @@ -31,7 +31,6 @@ redirect_if_major_upgrade_required(); $testsession = optional_param('testsession', 0, PARAM_INT); // test session works properly $anchor = optional_param('anchor', '', PARAM_RAW); // Used to restore hash anchor to wantsurl. -$logintoken = optional_param('logintoken', '', PARAM_RAW); // Used to validate the request. $resendconfirmemail = optional_param('resendconfirmemail', false, PARAM_BOOL); @@ -69,13 +68,13 @@ if (!empty($SESSION->has_timed_out)) { $session_has_timed_out = false; } -/// auth plugins may override these - SSO anyone? $frm = false; $user = false; $authsequence = get_enabled_auth_plugins(true); // auths, in sequence foreach($authsequence as $authname) { $authplugin = get_auth_plugin($authname); + // The auth plugin's loginpage_hook() can eventually set $frm and/or $user. $authplugin->loginpage_hook(); } @@ -134,12 +133,13 @@ if ($frm and isset($frm->username)) { // Login WITH } if ($user) { - //user already supplied by aut plugin prelogin hook + // The auth plugin has already provided the user via the loginpage_hook() called above. } else if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) { $user = false; /// Can't log in as guest if guest button is disabled $frm = false; } else { if (empty($errormsg)) { + $logintoken = isset($frm->logintoken) ? $frm->logintoken : ''; $user = authenticate_user_login($frm->username, $frm->password, false, $errorcode, $logintoken); } }