Fix Login.tsx to not redirect immediately after signin - let Auth context handle it

cgen-628b7dd547d74422b71ffd8765b30fd4
This commit is contained in:
Builder.io 2025-11-10 21:59:10 +00:00
parent 074b93f79e
commit e77e5d86f2

View file

@ -147,18 +147,15 @@ export default function Login() {
navigate("/onboarding", { replace: true }); navigate("/onboarding", { replace: true });
} }
} else { } else {
// Sign in with email/password
const result = await signIn(email, password); const result = await signIn(email, password);
if (result?.user) { if (result?.user) {
const params = new URLSearchParams(location.search); // Don't navigate immediately - let Auth context update and the useEffect below handle redirect
const next = params.get("next"); // This ensures profile data is fetched and profileComplete is properly calculated
const safeNext = next && next.startsWith("/") ? next : null; toastInfo({
navigate( title: "Signing you in",
safeNext || description: "Redirecting...",
(result?.user_metadata?.profile_complete });
? "/dashboard"
: "/onboarding"),
{ replace: true },
);
} }
} }
} catch (error: any) { } catch (error: any) {