Merge branch 'MDL-40805-master' of git://github.com/lameze/moodle

This commit is contained in:
Sam Hemelryk 2014-07-01 09:06:12 +12:00
commit a0145560b9
3 changed files with 39 additions and 15 deletions

View File

@ -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);
}
}
}

View File

@ -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) {
}
}
/**

View File

@ -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);
}
}
/**