Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): clear a stale onboarding continuation when signup has no next path

Richie McIlroya2f07a3f6e73
diff --git a/apps/web/app/(org)/onboarding-next.ts b/apps/web/app/(org)/onboarding-next.ts
index 57561b53b..e4f26f669 100644
--- a/apps/web/app/(org)/onboarding-next.ts
+++ b/apps/web/app/(org)/onboarding-next.ts
@@ -13,10 +13,14 @@ export const rememberOnboardingNextPath = (path: string) => {
});
};
+export const clearOnboardingNextPath = () => {
+ Cookies.remove(COOKIE_NAME, { path: "/" });
+};
+
export const consumeOnboardingNextPath = (fallback: string) => {
const value = Cookies.get(COOKIE_NAME);
if (value === undefined) return fallback;
- Cookies.remove(COOKIE_NAME, { path: "/" });
+ clearOnboardingNextPath();
const path = getSafeNextPath(value, window.location.origin);
return path === "/dashboard" ? fallback : path;
};
diff --git a/apps/web/app/(org)/signup/form.tsx b/apps/web/app/(org)/signup/form.tsx
index cc99c6330..b83835edd 100644
--- a/apps/web/app/(org)/signup/form.tsx
+++ b/apps/web/app/(org)/signup/form.tsx
@@ -28,7 +28,10 @@ import { getOrganizationSSOData } from "@/actions/organization/get-organization-
import { trackEvent } from "@/app/utils/analytics";
import { usePublicEnv } from "@/utils/public-env";
import { getEmailCodeCooldownSeconds, requestEmailCode } from "../auth-email";
-import { rememberOnboardingNextPath } from "../onboarding-next";
+import {
+ clearOnboardingNextPath,
+ rememberOnboardingNextPath,
+} from "../onboarding-next";
import { getSafeNextPath } from "../safe-next";
import { SsoErrorNotice } from "../sso-error-notice";
@@ -71,6 +74,7 @@ export function SignupForm() {
useEffect(() => {
const nextPath = getNextPath();
if (nextPath) rememberOnboardingNextPath(nextPath);
+ else clearOnboardingNextPath();
}, [getNextPath]);
useEffect(() => {