From 628ad823e35c524db9beb9039b7b66130d9c8659 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 9 Nov 2025 08:15:13 +0000 Subject: [PATCH] Fix Discord OAuth callback session handling cgen-d075ac5ea7ea407e9e174aebc9f11d0d --- client/pages/DiscordOAuthCallback.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/pages/DiscordOAuthCallback.tsx b/client/pages/DiscordOAuthCallback.tsx index 23eedfae..eeb63731 100644 --- a/client/pages/DiscordOAuthCallback.tsx +++ b/client/pages/DiscordOAuthCallback.tsx @@ -44,6 +44,7 @@ export default function DiscordOAuthCallback() { code, state: state || "/dashboard", }), + credentials: "include", // Include cookies in request }); const data = await response.json(); @@ -56,13 +57,20 @@ export default function DiscordOAuthCallback() { // Success setStatus("success"); - setMessage("Successfully linked! Redirecting..."); + setMessage(data.message || "Successfully authenticated!"); - // The backend handles session setup, so just redirect - const nextPath = state && state.startsWith("/") ? state : "/dashboard"; + // Save session tokens to localStorage if provided + if (data.session?.access_token) { + localStorage.setItem("sb-access-token", data.session.access_token); + localStorage.setItem("sb-refresh-token", data.session.refresh_token); + } + + // Redirect to next page + const nextPath = state && state.startsWith("/") ? state : data.isNewUser ? "/onboarding" : "/dashboard"; setTimeout(() => { navigate(nextPath); - }, 2000); + window.location.reload(); // Reload to pick up new auth context + }, 1500); } catch (error) { setStatus("error"); setMessage(