From 15446f2a7eca887d2135d2b8995759cd76550777 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Mon, 3 Jun 2024 12:08:02 -0400 Subject: [PATCH] Catch GitHub OAuth errors; log and show toast Co-Authored-By: Marcy Acevedo <32626323+MarcyLina@users.noreply.github.com> --- app/Http/Controllers/Auth/LoginController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 43ce5f6b..391f33ba 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -9,6 +9,7 @@ use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Log; use Illuminate\View\View; use Laravel\Socialite\Facades\Socialite; @@ -76,6 +77,13 @@ public function handleProviderCallback() return $userExists ? redirect(route_wlocale('modules.index')) : redirect()->intended(); } catch (Exception $e) { + if (request()->has('code') && request()->has('state')) { + Log::error($e); + + session()->flash('toast-title', 'GitHub Error'); + session()->flash('toast', 'There was an error authenticating with GitHub.'); + } + return redirect(route_wlocale('login')); } }