Discord socialite: catch InvalidStateException
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
use Laravel\Socialite\Two\InvalidStateException;
|
||||
|
||||
class DiscordAuthController extends Controller
|
||||
{
|
||||
@@ -26,7 +27,12 @@ class DiscordAuthController extends Controller
|
||||
*/
|
||||
public function callback(): RedirectResponse
|
||||
{
|
||||
$discordUser = Socialite::driver('discord')->user();
|
||||
try {
|
||||
$discordUser = Socialite::driver('discord')->user();
|
||||
} catch (InvalidStateException $e) {
|
||||
return redirect()->route('login')
|
||||
->with('error', 'Your login session expired. Please try signing in again.');
|
||||
}
|
||||
|
||||
$user = User::where('discord_id', $discordUser->id)->first();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user