Fix Login.tsx to not redirect immediately after signin - let Auth context handle it
cgen-628b7dd547d74422b71ffd8765b30fd4
This commit is contained in:
parent
074b93f79e
commit
e77e5d86f2
1 changed files with 7 additions and 10 deletions
|
|
@ -147,18 +147,15 @@ export default function Login() {
|
|||
navigate("/onboarding", { replace: true });
|
||||
}
|
||||
} else {
|
||||
// Sign in with email/password
|
||||
const result = await signIn(email, password);
|
||||
if (result?.user) {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const next = params.get("next");
|
||||
const safeNext = next && next.startsWith("/") ? next : null;
|
||||
navigate(
|
||||
safeNext ||
|
||||
(result?.user_metadata?.profile_complete
|
||||
? "/dashboard"
|
||||
: "/onboarding"),
|
||||
{ replace: true },
|
||||
);
|
||||
// Don't navigate immediately - let Auth context update and the useEffect below handle redirect
|
||||
// This ensures profile data is fetched and profileComplete is properly calculated
|
||||
toastInfo({
|
||||
title: "Signing you in",
|
||||
description: "Redirecting...",
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue