Skip to content

Commit 6e52d5a

Browse files
committed
Merge branch 'wip-110861-m401' into MOODLE_401_STABLE
# Conflicts: # local/o365/lang/en/local_o365.php
2 parents dc969b2 + ec27c68 commit 6e52d5a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

classes/utils.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Exception;
2929
use moodle_exception;
3030
use auth_oidc\event\action_failed;
31+
use moodle_url;
3132

3233
/**
3334
* General purpose utility class.
@@ -52,6 +53,18 @@ public static function process_json_response($response, array $expectedstructure
5253
$errmsg = 'Error response received.';
5354
self::debug($errmsg, __METHOD__, $result);
5455
if (isset($result['error_description'])) {
56+
$isadminconsent = optional_param('admin_consent', false, PARAM_BOOL);
57+
if ($isadminconsent) {
58+
if (get_config('auth_oidc', 'idptype') == AUTH_OIDC_IDP_TYPE_MICROSOFT_IDENTITY_PLATFORM &&
59+
auth_oidc_is_local_365_installed() &&
60+
$result['error'] === 'invalid_grant' &&
61+
isset($result['error_codes']) && count($result['error_codes']) == 1 &&
62+
$result['error_codes'][0] == 53003) {
63+
$localo365configurationpageurl = new moodle_url('/admin/settings.php', ['section' => 'local_o365']);
64+
throw new moodle_exception('settings_adminconsent_error_53003', 'local_o365',
65+
$localo365configurationpageurl, '', $result['error_description']);
66+
}
67+
}
5568
throw new moodle_exception('erroroidccall_message', 'auth_oidc', '', $result['error_description']);
5669
} else {
5770
throw new moodle_exception('erroroidccall', 'auth_oidc');
@@ -173,7 +186,7 @@ private static function make_json_safe($data) {
173186
* @return string The redirect URL.
174187
*/
175188
public static function get_redirecturl() {
176-
$redirecturl = new \moodle_url('/auth/oidc/');
189+
$redirecturl = new moodle_url('/auth/oidc/');
177190
return $redirecturl->out(false);
178191
}
179192

@@ -183,7 +196,7 @@ public static function get_redirecturl() {
183196
* @return string The redirect URL.
184197
*/
185198
public static function get_frontchannellogouturl() {
186-
$logouturl = new \moodle_url('/auth/oidc/logout.php');
199+
$logouturl = new moodle_url('/auth/oidc/logout.php');
187200
return $logouturl->out(false);
188201
}
189202

0 commit comments

Comments
 (0)