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 });
|
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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue