Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): don't bounce /reset-password to /onboarding for un-onboarded accounts (#13511)

Reinier van der Leer69837087108e
diff --git a/autogpt_platform/frontend/src/providers/onboarding/__tests__/onboarding-provider-routing.test.tsx b/autogpt_platform/frontend/src/providers/onboarding/__tests__/onboarding-provider-routing.test.tsx
index cd977675ca..78273cbae2 100644
--- a/autogpt_platform/frontend/src/providers/onboarding/__tests__/onboarding-provider-routing.test.tsx
+++ b/autogpt_platform/frontend/src/providers/onboarding/__tests__/onboarding-provider-routing.test.tsx
@@ -140,6 +140,24 @@ describe("OnboardingProvider routing — logged-in user", () => {
);
});
+ test("incomplete user on /reset-password stays put (recovery session must set password first)", async () => {
+ // A Supabase recovery link signs the user in and lands them on
+ // /reset-password. Bouncing them to /onboarding would skip the password
+ // change entirely, turning the reset link into a one-time sign-in link.
+ mockPathname = "/reset-password";
+ mockIsCompleted = false;
+
+ render(
+ <OnboardingProvider>
+ <div data-testid="child" />
+ </OnboardingProvider>,
+ );
+
+ await new Promise((r) => setTimeout(r, 30));
+ expect(routerReplace).not.toHaveBeenCalled();
+ expect(completedCallCount.value).toBe(0);
+ });
+
test("incomplete user already on /onboarding stays put", async () => {
mockPathname = "/onboarding";
mockIsCompleted = false;
diff --git a/autogpt_platform/frontend/src/providers/onboarding/onboarding-provider.tsx b/autogpt_platform/frontend/src/providers/onboarding/onboarding-provider.tsx
index f512c12e15..339f8bc566 100644
--- a/autogpt_platform/frontend/src/providers/onboarding/onboarding-provider.tsx
+++ b/autogpt_platform/frontend/src/providers/onboarding/onboarding-provider.tsx
@@ -119,6 +119,11 @@ export default function OnboardingProvider({
// trigger onboarding init/redirects (which would bounce a logged-in user with
// incomplete onboarding out of the tour).
const isOnPublicTour = pathname.startsWith("/tour");
+ // A Supabase recovery link signs the user in and lands them on
+ // /reset-password. They must stay there until the new password is set;
+ // bouncing an un-onboarded account to /onboarding would skip the password
+ // change and turn the reset link into a one-time sign-in link.
+ const isOnPasswordResetRoute = pathname.startsWith("/reset-password");
// Logged-in users sitting on the auth pages need to be routed onward by us;
// otherwise the signup/login pages show their `isLoggedIn` loader forever.
// Handling them here (instead of in useSignupPage/useLoginPage) avoids the
@@ -154,8 +159,14 @@ export default function OnboardingProvider({
}, [isLoggedIn, isOnAuthRoute]);
useEffect(() => {
- // Prevent multiple initializations
- if (hasInitialized.current || !isLoggedIn || isOnPublicTour) {
+ // Prevent multiple initializations. Skipped routes don't mark
+ // hasInitialized, so init re-runs on the next pathname change.
+ if (
+ hasInitialized.current ||
+ !isLoggedIn ||
+ isOnPublicTour ||
+ isOnPasswordResetRoute
+ ) {
return;
}
@@ -221,6 +232,7 @@ export default function OnboardingProvider({
isLoggedIn,
pathname,
isOnPublicTour,
+ isOnPasswordResetRoute,
]);
const handleOnboardingNotification = useCallback(