diff --git a/web/src/app/auth/login/EmailPasswordForm.tsx b/web/src/app/auth/login/EmailPasswordForm.tsx index 06053fae5f2..5802f0d35fe 100644 --- a/web/src/app/auth/login/EmailPasswordForm.tsx +++ b/web/src/app/auth/login/EmailPasswordForm.tsx @@ -15,10 +15,12 @@ export function EmailPasswordForm({ isSignup = false, shouldVerify, referralSource, + nextUrl, }: { isSignup?: boolean; shouldVerify?: boolean; referralSource?: string; + nextUrl?: string | null; }) { const router = useRouter(); const { popup, setPopup } = usePopup(); @@ -69,7 +71,7 @@ export function EmailPasswordForm({ await requestEmailVerification(values.email); router.push("/auth/waiting-on-verification"); } else { - router.push("/"); + router.push(nextUrl ? encodeURI(nextUrl) : "/"); } } else { setIsWorking(false); diff --git a/web/src/app/auth/login/page.tsx b/web/src/app/auth/login/page.tsx index fc72c41719f..7a6459655ca 100644 --- a/web/src/app/auth/login/page.tsx +++ b/web/src/app/auth/login/page.tsx @@ -22,6 +22,9 @@ const Page = async (props: { }) => { const searchParams = await props.searchParams; const autoRedirectDisabled = searchParams?.disableAutoRedirect === "true"; + const nextUrl = Array.isArray(searchParams?.next) + ? searchParams?.next[0] + : searchParams?.next || null; // catch cases where the backend is completely unreachable here // without try / catch, will just raise an exception and the page @@ -37,10 +40,6 @@ const Page = async (props: { console.log(`Some fetch failed for the login page - ${e}`); } - const nextUrl = Array.isArray(searchParams?.next) - ? searchParams?.next[0] - : searchParams?.next || null; - // simply take the user to the home page if Auth is disabled if (authTypeMetadata?.authType === "disabled") { return redirect("/"); @@ -100,12 +99,15 @@ const Page = async (props: { or
-