From 5de087117101c871c83f924faefd0a1e6ab3acb4 Mon Sep 17 00:00:00 2001 From: Dmitrii Metelkin Date: Fri, 19 Aug 2016 11:54:39 +1000 Subject: [PATCH] Add logout redirection functionality --- auth.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/auth.php b/auth.php index 4c3a339..e7fe341 100644 --- a/auth.php +++ b/auth.php @@ -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; + } + } }