Skip to content

Commit

Permalink
MDL-60827 oauth2: Consider requireconfirmation setting on login
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Geshoski committed Jul 6, 2020
1 parent 49a9e8b commit ecf15a6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions auth/oauth2/classes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,9 @@ public function complete_login(client $client, $redirecturl) {
}
}

$issuer = $client->get_issuer();
// First we try and find a defined mapping.
$linkedlogin = api::match_username_to_user($userinfo['username'], $client->get_issuer());
$linkedlogin = api::match_username_to_user($userinfo['username'], $issuer);

if (!empty($linkedlogin) && empty($linkedlogin->get('confirmtoken'))) {
$mappeduser = get_complete_user_data('id', $linkedlogin->get('userid'));
Expand All @@ -474,7 +475,7 @@ public function complete_login(client $client, $redirecturl) {
$SESSION->loginerrormsg = get_string('invalidlogin');
$client->log_out();
redirect(new moodle_url('/login/index.php'));
} else if ($mappeduser && $mappeduser->confirmed) {
} else if ($mappeduser && ($mappeduser->confirmed || !$issuer->get('requireconfirmation'))) {
// Update user fields.
$userinfo = $this->update_user($userinfo, $mappeduser);
$userwasmapped = true;
Expand Down Expand Up @@ -503,7 +504,7 @@ public function complete_login(client $client, $redirecturl) {
redirect(new moodle_url('/login/index.php'));
}

$issuer = $client->get_issuer();

if (!$issuer->is_valid_login_domain($oauthemail)) {
// Trigger login failed event.
$failurereason = AUTH_LOGIN_UNAUTHORISED;
Expand Down

0 comments on commit ecf15a6

Please sign in to comment.