Prevent error where user is already logged in

This commit is contained in:
Andrew Hancox 2018-01-22 22:16:36 +00:00
parent eea400f30f
commit bb426a5adb

View file

@ -142,6 +142,16 @@ class auth_plugin_userkey extends auth_plugin_base {
$keyvalue = required_param('key', PARAM_ALPHANUM); $keyvalue = required_param('key', PARAM_ALPHANUM);
$wantsurl = optional_param('wantsurl', '', PARAM_URL); $wantsurl = optional_param('wantsurl', '', PARAM_URL);
if (!empty($wantsurl)) {
$redirecturl = $wantsurl;
} else {
$redirecturl = $CFG->wwwroot;
}
if (isloggedin()) {
$this->redirect($redirecturl);
}
$key = $this->userkeymanager->validate_key($keyvalue); $key = $this->userkeymanager->validate_key($keyvalue);
$this->userkeymanager->delete_keys($key->userid); $this->userkeymanager->delete_keys($key->userid);
@ -151,12 +161,6 @@ class auth_plugin_userkey extends auth_plugin_base {
// Identify this session as using user key auth method. // Identify this session as using user key auth method.
$SESSION->userkey = true; $SESSION->userkey = true;
if (!empty($wantsurl)) {
$redirecturl = $wantsurl;
} else {
$redirecturl = $CFG->wwwroot;
}
$this->redirect($redirecturl); $this->redirect($redirecturl);
} }