Merge branch 'MDL-60827-master' of git://github.com/mihailges/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2020-07-07 00:14:34 +02:00
commit 70e973d092

View File

@ -455,8 +455,9 @@ class auth extends \auth_plugin_base {
}
}
$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'));
@ -474,7 +475,7 @@ class auth extends \auth_plugin_base {
$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;
@ -503,7 +504,7 @@ class auth extends \auth_plugin_base {
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;