Merge pull request #22 from andrewhancox/master
Prevent error where user is already logged in
This commit is contained in:
commit
c7e17febb5
1 changed files with 10 additions and 6 deletions
16
auth.php
16
auth.php
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue