Change user_login_userkey() to return redirect URL

This commit is contained in:
Dmitrii Metelkin 2016-08-18 22:56:53 +10:00
parent 8341a1ac40
commit a3fa1f0254
2 changed files with 9 additions and 6 deletions

View file

@ -80,15 +80,17 @@ class auth_plugin_userkey extends auth_plugin_base {
}
/**
* Login user using userkey.
* Login user using userkey and return URL to redirect after.
*
* This is basically customised core require_user_key_login().
* @return mixed|string URL to redirect.
*
* @throws \moodle_exception If something went wrong.
*/
public function user_login_userkey() {
global $DB;
$keyvalue = required_param('key', PARAM_ALPHANUM);
$wantsurl = optional_param('wantsurl', '', PARAM_LOCALURL);
$wantsurl = optional_param('wantsurl', '', PARAM_URL);
$options = array(
'script' => core_userkey_manager::CORE_USER_KEY_MANAGER_SCRIPT,
@ -126,9 +128,9 @@ class auth_plugin_userkey extends auth_plugin_base {
complete_user_login($user);
if (!empty($wantsurl)) {
redirect($wantsurl);
return $wantsurl;
} else {
redirect('/');
return '/';
}
}

View file

@ -28,4 +28,5 @@ if (!is_enabled_auth('userkey')) {
print_error(get_string('pluginisdisabled', 'auth_userkey'));
}
get_auth_plugin('userkey')->user_login_userkey();
$redirect = get_auth_plugin('userkey')->user_login_userkey();
redirect($redirect);