Merge pull request #22 from andrewhancox/master

Prevent error where user is already logged in
This commit is contained in:
Dmitrii Metelkin 2018-01-29 10:11:18 +11:00 committed by GitHub
commit c7e17febb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -142,6 +142,16 @@ class auth_plugin_userkey extends auth_plugin_base {
$keyvalue = required_param('key', PARAM_ALPHANUM);
$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);
$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.
$SESSION->userkey = true;
if (!empty($wantsurl)) {
$redirecturl = $wantsurl;
} else {
$redirecturl = $CFG->wwwroot;
}
$this->redirect($redirecturl);
}