Add logout redirection functionality

This commit is contained in:
Dmitrii Metelkin 2016-08-19 11:54:39 +10:00
parent b24d466649
commit 5de0871171

View file

@ -88,7 +88,7 @@ class auth_plugin_userkey extends auth_plugin_base {
* @throws \moodle_exception If something went wrong.
*/
public function user_login_userkey() {
global $DB;
global $DB, $SESSION;
$keyvalue = required_param('key', PARAM_ALPHANUM);
$wantsurl = optional_param('wantsurl', '', PARAM_URL);
@ -127,6 +127,9 @@ class auth_plugin_userkey extends auth_plugin_base {
$user = get_complete_user_data('id', $user->id);
complete_user_login($user);
// Identify this session as using user key auth method.
$SESSION->userkey = true;
if (!empty($wantsurl)) {
return $wantsurl;
} else {
@ -380,4 +383,19 @@ class auth_plugin_userkey extends auth_plugin_base {
return $parameters;
}
/**
* Logout page hook.
*
* Override redirect URL after logout.
*
* @see auth_plugin_base::logoutpage_hook()
*/
public function logoutpage_hook() {
global $redirect, $SESSION;
if (!empty($this->config->redirecturl) && isset($SESSION->userkey)) {
$redirect = $this->config->redirecturl;
}
}
}