Skip to content

Commit

Permalink
try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Sep 17, 2024
1 parent 388fccc commit 946e69b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Session;
use Inertia\Inertia;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\InvalidStateException;

class AuthController extends Controller
{
Expand All @@ -27,7 +28,11 @@ public function login()

public function loginCallback()
{
$user = Socialite::driver('identity')->user();
try {
$user = Socialite::driver('identity')->user();
} catch (InvalidStateException $e) {
return redirect()->route('auth.login');
}
if (!in_array('54ZYODX15G2K1M76', $user->user['groups'], true)) {
return redirect()->route('auth.login')->with('error', 'You are not allowed to access this application');
}
Expand Down

0 comments on commit 946e69b

Please sign in to comment.