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): route the unverified email banner to the code entry page (#96456)

Alex Lidera3f0e9c60499
diff --git a/frontend/src/layout/navigation/projectNoticeLogic.test.tsx b/frontend/src/layout/navigation/projectNoticeLogic.test.tsx
index d2e7f77d3749..4df015f803c4 100644
--- a/frontend/src/layout/navigation/projectNoticeLogic.test.tsx
+++ b/frontend/src/layout/navigation/projectNoticeLogic.test.tsx
@@ -1,4 +1,4 @@
-import { MOCK_TEAM_ID } from 'lib/api.mock'
+import { MOCK_DEFAULT_USER, MOCK_TEAM_ID } from 'lib/api.mock'
import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -11,6 +11,7 @@ import { verifyEmailLogic } from 'scenes/authentication/verify-email/verifyEmail
import { billingLogic } from 'scenes/billing/billingLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
+import { userLogic } from 'scenes/userLogic'
import { useMocks } from '~/mocks/jest'
import { ProductKey } from '~/queries/schema/schema-general'
@@ -292,6 +293,29 @@ describe('projectNoticeLogic', () => {
logic.unmount()
})
+
+ // The verification email carries a 6-digit code, not a link. A CTA that only sends the
+ // code leaves a logged-in user (Vercel-provisioned accounts hit this) with nowhere to type it.
+ it('sends a code and routes to the code entry page when the banner CTA is clicked', async () => {
+ preflightLogic.actions.loadPreflightSuccess({ email_service_available: true } as any)
+ userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_email_verified: false })
+ router.actions.push(urls.settings('user'))
+
+ const logic = projectNoticeLogic()
+ logic.mount()
+
+ expect(logic.values.projectNoticeVariant).toEqual('unverified_email')
+
+ await expectLogic(verifyEmailLogic, () => {
+ logic.values.projectNotice?.action?.onClick?.({} as any)
+ }).toDispatchActions(['requestVerificationCode', 'requestVerificationCodeSuccess'])
+
+ // Routing prefixes the current project, so assert the targets rather than exact paths.
+ expect(router.values.location.pathname).toMatch(new RegExp(`${urls.verifyEmail(MOCK_DEFAULT_USER.uuid)}$`))
+ expect(router.values.searchParams.next).toMatch(new RegExp(`${urls.settings('user')}$`))
+
+ logic.unmount()
+ })
})
describe('reverse proxy banner CTA navigation', () => {
diff --git a/frontend/src/layout/navigation/projectNoticeLogic.tsx b/frontend/src/layout/navigation/projectNoticeLogic.tsx
index ac8489027973..7aa45561a885 100644
--- a/frontend/src/layout/navigation/projectNoticeLogic.tsx
+++ b/frontend/src/layout/navigation/projectNoticeLogic.tsx
@@ -353,7 +353,7 @@ export const projectNoticeLogic = kea<projectNoticeLogicType>([
actions: [
eventUsageLogic,
['reportProjectNoticeDismissed', 'reportProjectNoticeShown'],
- // Mount verifyEmailLogic so the "Send verification email" banner CTA's loader fires.
+ // Mount verifyEmailLogic so the "Verify email" banner CTA's loader fires.
// The banner renders on every scene, but verifyEmailLogic is otherwise only mounted on the verify-email scene.
verifyEmailLogic,
['requestVerificationCode'],
@@ -665,8 +665,17 @@ export const projectNoticeLogic = kea<projectNoticeLogicType>([
message: 'Please verify your email address.',
action: {
'data-attr': 'unverified-email-cta',
- onClick: () => user && verifyEmailLogic.actions.requestVerificationCode(user.uuid),
- children: 'Send verification email',
+ onClick: () => {
+ if (!user) {
+ return
+ }
+ verifyEmailLogic.actions.requestVerificationCode(user.uuid)
+ // The email carries a 6-digit code, and only the verify-email scene has the
+ // entry form. `next` returns the user to this page once the code is accepted.
+ const { pathname, search, hash } = router.values.location
+ router.actions.push(urls.verifyEmail(user.uuid), { next: pathname + search + hash })
+ },
+ children: 'Verify email',
},
type: 'warning',
}