Add support for OAuth redirect destination from sessionStorage

cgen-c246145e22f04784a62477f2ebc383c3
This commit is contained in:
Builder.io 2025-11-10 19:28:22 +00:00
parent 6457e7479b
commit c3ccf53d07

View file

@ -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,
});
}