Skip to content

Commit

Permalink
Fix: catalyst#60 User sporadically not logged in, after autocreate
Browse files Browse the repository at this point in the history
We do not call require_logout, in cases where the user is logged in anyways afterwards.
Additionally, in case of an error also we do not destroy the existing session
  • Loading branch information
amenk authored Oct 28, 2020
1 parent 4e151b4 commit c2d1e2d
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,11 @@ public function user_login_userkey() {
try {
$key = $this->userkeymanager->validate_key($keyvalue);
} catch (moodle_exception $exception) {
// If user is logged in and key is not valid, we'd like to logout a user.
if (isloggedin()) {
require_logout();
}
print_error($exception->errorcode);
}

if (isloggedin()) {
if ($USER->id != $key->userid) {
// Logout the current user if it's different to one that associated to the valid key.
require_logout();
} else {
if ($USER->id == $key->userid) {
// Don't process further if the user is already logged in.
$this->userkeymanager->delete_keys($key->userid);
$this->redirect($redirecturl);
Expand Down

0 comments on commit c2d1e2d

Please sign in to comment.