Skip to content

Commit 9c3f679

Browse files
committed
fix(frontend): simplify login redirect
1 parent 9977144 commit 9c3f679

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

autogpt_platform/frontend/src/app/(platform)/login/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export async function login(
5555
return {
5656
success: true,
5757
onboarding,
58-
next: onboarding ? "/onboarding" : "/",
5958
};
6059
} catch (err) {
6160
Sentry.captureException(err);
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
export function computeReturnURL(returnUrl: string | null, result: any) {
2-
return returnUrl
3-
? returnUrl
4-
: (result?.next as string) || (result?.onboarding ? "/onboarding" : "/");
5-
}

autogpt_platform/frontend/src/app/(platform)/login/useLoginPage.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
44
import { environment } from "@/services/environment";
55
import { loginFormSchema, LoginProvider } from "@/types/auth";
66
import { zodResolver } from "@hookform/resolvers/zod";
7-
import { useRouter, useSearchParams } from "next/navigation";
7+
import { useRouter } from "next/navigation";
88
import { useCallback, useState } from "react";
99
import { useForm } from "react-hook-form";
1010
import z from "zod";
1111
import { login as loginAction } from "./actions";
12-
import { computeReturnURL } from "./helpers";
1312

1413
export function useLoginPage() {
1514
const { supabase, user, isUserLoading } = useSupabase();
1615
const [feedback, setFeedback] = useState<string | null>(null);
1716
const [captchaKey, setCaptchaKey] = useState(0);
1817
const router = useRouter();
19-
const searchParams = useSearchParams();
20-
const returnUrl = searchParams.get("returnUrl");
2118
const { toast } = useToast();
2219
const [isLoading, setIsLoading] = useState(false);
2320
const [isGoogleLoading, setIsGoogleLoading] = useState(false);
@@ -117,9 +114,11 @@ export function useLoginPage() {
117114
throw new Error(result.error || "Login failed");
118115
}
119116

120-
// Prioritize returnUrl from query params over backend's onboarding logic
121-
const next = computeReturnURL(returnUrl, result);
122-
if (next) router.replace(next);
117+
if (result.onboarding) {
118+
router.replace("/onboarding");
119+
} else {
120+
router.replace("/marketplace");
121+
}
123122
} catch (error) {
124123
toast({
125124
title:

0 commit comments

Comments
 (0)