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\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Laravel\Socialite\Facades\Socialite;
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
use Laravel\Socialite\Two\InvalidStateException;
|
||||||
|
|
||||||
class DiscordAuthController extends Controller
|
class DiscordAuthController extends Controller
|
||||||
{
|
{
|
||||||
@@ -26,7 +27,12 @@ class DiscordAuthController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function callback(): RedirectResponse
|
public function callback(): RedirectResponse
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$discordUser = Socialite::driver('discord')->user();
|
$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();
|
$user = User::where('discord_id', $discordUser->id)->first();
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="mb-4 rounded-md bg-red-200 p-4 border border-red-200">
|
||||||
|
<div class="text-sm text-red-700">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Or -->
|
<!-- Or -->
|
||||||
<div class="grid grid-cols-3">
|
<div class="grid grid-cols-3">
|
||||||
<hr class="self-center border-neutral-600">
|
<hr class="self-center border-neutral-600">
|
||||||
|
|||||||
Reference in New Issue
Block a user