Skip to content

Commit 0320fe5

Browse files
Merge pull request #34 from JustinByrne/patch-2
returned missing code to get error description
2 parents 5ebceb5 + 4e616ab commit 0320fe5

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/Azure.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,23 @@ protected function success(Request $request, $access_token, $refresh_token, $pro
187187
protected function fail(Request $request, \Exception $e)
188188
{
189189
// JustinByrne updated the original code from smitthhyy (18 Dec 2019) to change to an array to allow for multiple error codes.
190-
$azureErrors = [
191-
'AADSTS50105' => [
192-
'HTTP_CODE' => '403',
193-
'msg' => 'User is not authorized within Azure AD to access this application.',
194-
],
195-
'AADSTS90072' => [
196-
'HTTP_CODE' => '403',
197-
'msg' => 'The logged on User is not in the allowed Tenant. Log in with a User in the allowed Tenant.',
198-
],
199-
];
200-
201-
if (array_key_exists($errorDescription, $azureErrors)) {
202-
return abort($azureErrors[$errorDescription]['HTTP_CODE'], $azureErrors[$errorDescription]['msg']);
190+
if ($request->isMethod('get')) {
191+
$errorDescription = trim(substr($request->query('error_description', 'SOMETHING_ELSE'), 0, 11));
192+
193+
$azureErrors = [
194+
'AADSTS50105' => [
195+
'HTTP_CODE' => '403',
196+
'msg' => 'User is not authorized within Azure AD to access this application.',
197+
],
198+
'AADSTS90072' => [
199+
'HTTP_CODE' => '403',
200+
'msg' => 'The logged on User is not in the allowed Tenant. Log in with a User in the allowed Tenant.',
201+
],
202+
];
203+
204+
if (array_key_exists($errorDescription, $azureErrors)) {
205+
return abort($azureErrors[$errorDescription]['HTTP_CODE'], $azureErrors[$errorDescription]['msg']);
206+
}
203207
}
204208

205209
return implode("", explode(PHP_EOL, $e->getMessage()));

0 commit comments

Comments
 (0)