handle failed oauth (#1264)

* handle failed oauths

* fix linter

* small cleanup

---------

Co-authored-by: Boy132 <mail@boy132.de>
This commit is contained in:
Letter N 2025-04-23 03:57:44 +08:00 committed by GitHub
parent 0e2ab4b711
commit 058b613c98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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