mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-40805 auth_cas : Method postlogout_hook created to be executed after user_loggedout event trigger.
This commit is contained in:
parent
7784c3ad18
commit
f9f9d187f8
@ -162,19 +162,6 @@ class auth_plugin_cas extends auth_plugin_ldap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout from the CAS
|
||||
*
|
||||
*/
|
||||
function prelogout_hook() {
|
||||
global $CFG;
|
||||
|
||||
if (!empty($this->config->logoutcas)) {
|
||||
$backurl = $CFG->wwwroot;
|
||||
$this->connectCAS();
|
||||
phpCAS::logoutWithURL($backurl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the CAS (clientcas connection or proxycas connection)
|
||||
@ -510,4 +497,22 @@ class auth_plugin_cas extends auth_plugin_ldap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post logout hook.
|
||||
*
|
||||
* Note: this method replace the prelogout_hook method to avoid redirect to CAS logout
|
||||
* before the event userlogout being triggered.
|
||||
*
|
||||
* @param stdClass $user clone of USER object object before the user session was terminated
|
||||
*/
|
||||
public function postlogout_hook($user) {
|
||||
global $CFG;
|
||||
// Only redirect to CAS logout if the user is logged as a CAS user.
|
||||
if (!empty($this->config->logoutcas) && $user->auth == $this->authtype) {
|
||||
$backurl = $CFG->wwwroot;
|
||||
$this->connectCAS();
|
||||
phpCAS::logoutWithRedirectService($backurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -566,6 +566,16 @@ class auth_plugin_base {
|
||||
|
||||
return $this->customfields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post logout hook.
|
||||
*
|
||||
* This method is used after moodle logout by auth classes to execute server logout.
|
||||
*
|
||||
* @param stdClass $user clone of USER object before the user session was terminated
|
||||
*/
|
||||
public function postlogout_hook($user) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3162,10 +3162,11 @@ function require_logout() {
|
||||
}
|
||||
|
||||
// Execute hooks before action.
|
||||
$authplugins = array();
|
||||
$authsequence = get_enabled_auth_plugins();
|
||||
foreach ($authsequence as $authname) {
|
||||
$authplugin = get_auth_plugin($authname);
|
||||
$authplugin->prelogout_hook();
|
||||
$authplugins[$authname] = get_auth_plugin($authname);
|
||||
$authplugins[$authname]->prelogout_hook();
|
||||
}
|
||||
|
||||
// Store info that gets removed during logout.
|
||||
@ -3181,11 +3182,19 @@ function require_logout() {
|
||||
$event->add_record_snapshot('sessions', $session);
|
||||
}
|
||||
|
||||
// Clone of $USER object to be used by auth plugins.
|
||||
$user = fullclone($USER);
|
||||
|
||||
// Delete session record and drop $_SESSION content.
|
||||
\core\session\manager::terminate_current();
|
||||
|
||||
// Trigger event AFTER action.
|
||||
$event->trigger();
|
||||
|
||||
// Hook to execute auth plugins redirection after event trigger.
|
||||
foreach ($authplugins as $authplugin) {
|
||||
$authplugin->postlogout_hook($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user