From c3ccf53d07416814f1d5ded715c0eea8d7d84277 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 19:28:22 +0000 Subject: [PATCH] Add support for OAuth redirect destination from sessionStorage cgen-c246145e22f04784a62477f2ebc383c3 --- client/pages/Login.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/pages/Login.tsx b/client/pages/Login.tsx index bf56df26..84cd835f 100644 --- a/client/pages/Login.tsx +++ b/client/pages/Login.tsx @@ -105,8 +105,20 @@ export default function Login() { if (!loading && user) { const params = new URLSearchParams(location.search); const next = params.get("next"); - const safeNext = next && next.startsWith("/") ? next : null; - navigate(safeNext || (profileComplete ? "/dashboard" : "/onboarding"), { + + // Check if there's an OAuth redirect destination stored (e.g., from staff login) + const oauthRedirect = sessionStorage.getItem("oauth_redirect_to"); + const redirectDest = + (next && next.startsWith("/") ? next : null) || + oauthRedirect || + (profileComplete ? "/dashboard" : "/onboarding"); + + // Clear the stored redirect after using it + if (oauthRedirect) { + sessionStorage.removeItem("oauth_redirect_to"); + } + + navigate(redirectDest, { replace: true, }); }