From 058b613c984944ecc71bf9590bbe8695c66d4882 Mon Sep 17 00:00:00 2001 From: Letter N <24603524+LetterN@users.noreply.github.com> Date: Wed, 23 Apr 2025 03:57:44 +0800 Subject: [PATCH] handle failed oauth (#1264) * handle failed oauths * fix linter * small cleanup --------- Co-authored-by: Boy132 --- app/Http/Controllers/Auth/OAuthController.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index 672b204b0..313bca976 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -44,6 +44,20 @@ class OAuthController extends Controller return redirect()->route('auth.login'); } + // Check for errors (https://www.oauth.com/oauth2-servers/server-side-apps/possible-errors/) + if ($request->get('error')) { + report($request->get('error_description') ?? $request->get('error')); + + Notification::make() + ->title('Something went wrong') + ->body($request->get('error')) + ->danger() + ->persistent() + ->send(); + + return redirect()->route('auth.login'); + } + $oauthUser = Socialite::driver($driver)->user(); // User is already logged in and wants to link a new OAuth Provider