diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5a5aed8..ce245cf 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -52,11 +52,11 @@ private function setJWTGuard(): void return response()->json(['error' => 'Invalid token, '.$e->getMessage()], 401); } - if (! in_array($decoded->aud, config('oauth.trusted_aud'))) { - return response()->json(['error' => 'The application rejected the token, token aud is '.$decoded->aud.', app aud is '.config('oauth.client_id')], 401); - } + if (config('oauth.force_aud')) { + if (! in_array($decoded->aud, config('oauth.trusted_aud'))) { + return response()->json(['error' => 'The application rejected the token, token aud is '.$decoded->aud.', app aud is '.config('oauth.client_id')], 401); + } - if (config('oauth.force_aud') && $decoded->aud != config('oauth.client_id')) { return response()->json(['error' => 'The token not match the application, '.' token aud is '.$decoded->aud.', app aud is '.config('oauth.client_id')], 401); }