Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(auth): exempt verify_email route from onboarding redirect (#67211)

Reece Jones9dad2a2df022
diff --git a/frontend/src/scenes/sceneLogic.test.ts b/frontend/src/scenes/sceneLogic.test.ts
index 626bbbb4db08..d0420e38cfd6 100644
--- a/frontend/src/scenes/sceneLogic.test.ts
+++ b/frontend/src/scenes/sceneLogic.test.ts
@@ -1,6 +1,18 @@
-import { withForwardedSearchParams } from './sceneLogic'
+import { isOnboardingNotRequiredForPath, withForwardedSearchParams } from './sceneLogic'
describe('sceneLogic', () => {
+ describe('isOnboardingNotRequiredForPath', () => {
+ // Regression guard: a mid-onboarding user clicking the email-change confirmation link must not
+ // be bounced to /onboarding before verifyEmailLogic can run, or the email is never updated.
+ it.each<[string, boolean]>([
+ ['/verify_email/some-uuid/some-token', true],
+ ['/project/492200/verify_email/some-uuid/some-token', true],
+ ['/project/492200/dashboard/1', false],
+ ])('isOnboardingNotRequiredForPath(%s) === %s', (path, expected) => {
+ expect(isOnboardingNotRequiredForPath(path)).toBe(expected)
+ })
+ })
+
describe('withForwardedSearchParams', () => {
it('returns original URL when no params to forward', () => {
const redirectUrl = '/dashboard'
diff --git a/frontend/src/scenes/sceneLogic.tsx b/frontend/src/scenes/sceneLogic.tsx
index 4880f5e764d6..7c47b57a78e6 100644
--- a/frontend/src/scenes/sceneLogic.tsx
+++ b/frontend/src/scenes/sceneLogic.tsx
@@ -106,11 +106,20 @@ const pathPrefixesOnboardingNotRequiredFor = [
'/agentic',
// /cli/authorize, /cli/live (CLI auth round-trip).
'/cli',
+ // /verify_email/<uuid>/<token> — email verification/change confirmation must run its
+ // urlToAction (POST /api/users/verify_email/) even when onboarding is incomplete, else
+ // /onboarding swallows the click and the email is never updated.
+ urls.verifyEmail(),
'/startups',
'/coupons',
'/legal',
]
+export function isOnboardingNotRequiredForPath(pathname: string): boolean {
+ const path = removeProjectIdIfPresent(pathname)
+ return pathPrefixesOnboardingNotRequiredFor.some((prefix) => path.startsWith(prefix))
+}
+
const DelayedLoadingSpinner = (): JSX.Element => {
const [show, setShow] = useState(false)
useEffect(() => {
@@ -626,9 +635,7 @@ export const sceneLogic = kea<sceneLogicType>([
// If the delegation invite is cancelled or expires, the backend clears
// onboarding_delegated_to_invite and the redirect re-fires.
!isOnboardingRedirectSuppressed(user) &&
- !pathPrefixesOnboardingNotRequiredFor.some((path) =>
- removeProjectIdIfPresent(location.pathname).startsWith(path)
- )
+ !isOnboardingNotRequiredForPath(location.pathname)
) {
const nextUrl =
getRelativeNextPath(params.searchParams.next, location) ??