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
- +
Don't have an account?{" "} - + Create an account @@ -120,11 +122,14 @@ const Page = async (props: {
- +
Don't have an account?{" "} - + Create an account diff --git a/web/src/app/auth/signup/page.tsx b/web/src/app/auth/signup/page.tsx index 223faff331d..105c79bae60 100644 --- a/web/src/app/auth/signup/page.tsx +++ b/web/src/app/auth/signup/page.tsx @@ -15,7 +15,15 @@ import AuthFlowContainer from "@/components/auth/AuthFlowContainer"; import ReferralSourceSelector from "./ReferralSourceSelector"; import { Separator } from "@/components/ui/separator"; -const Page = async () => { +const Page = async ({ + searchParams, +}: { + searchParams: { [key: string]: string | string[] | undefined }; +}) => { + 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 // will not render @@ -86,12 +94,19 @@ const Page = async () => {
Already have an account?{" "} - + Log In