Honor next query param after login

cgen-5835fa17c9d447c88d8e17ea9c138783
This commit is contained in:
Builder.io 2025-10-19 00:53:17 +00:00
parent 98f602b024
commit 7be1e9a738

View file

@ -63,14 +63,17 @@ export default function Login() {
} = useAuth();
const { info: toastInfo, error: toastError } = useAethexToast();
// After auth resolves and a user exists, navigate to dashboard
// After auth resolves and a user exists, navigate to next path or dashboard
useEffect(() => {
if (!loading && user) {
navigate(profileComplete ? "/dashboard" : "/onboarding", {
const params = new URLSearchParams(location.search);
const next = params.get("next");
const safeNext = next && next.startsWith("/") ? next : null;
navigate(safeNext || (profileComplete ? "/dashboard" : "/onboarding"), {
replace: true,
});
}
}, [user, loading, profileComplete, navigate]);
}, [user, loading, profileComplete, navigate, location.search]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();