Honor next query param after login
cgen-5835fa17c9d447c88d8e17ea9c138783
This commit is contained in:
parent
98f602b024
commit
7be1e9a738
1 changed files with 6 additions and 3 deletions
|
|
@ -63,14 +63,17 @@ export default function Login() {
|
||||||
} = useAuth();
|
} = useAuth();
|
||||||
const { info: toastInfo, error: toastError } = useAethexToast();
|
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(() => {
|
useEffect(() => {
|
||||||
if (!loading && user) {
|
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,
|
replace: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [user, loading, profileComplete, navigate]);
|
}, [user, loading, profileComplete, navigate, location.search]);
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue