Files
Pamela Chia f678d3682f fix(studio): load PostHog flags after MFA verification (#53587)
For a user with MFA enabled, Studio requests PostHog flags once with the
pre-MFA token, the API refuses it, and nothing requests them again after
the challenge is verified. The flags stay missing until the user opens
an organization or project, or reloads, so pages reached straight after
MFA (`/organizations`, `/new`, `/account`) get no flag values.

I made `FeatureFlagProvider` refetch when the auth client reports a
verified MFA challenge. Verification changes none of the existing fetch
inputs (user, organization, project), which is why the refused first
response stuck.

**Note:** The refetch runs on any verified MFA challenge (sign-in,
enrolling a factor, identity re-verification), so users who never verify
a challenge make the same flag requests as before. I did not key it on
the access token, because that would refetch on every token refresh.

## To test

Tested on the PR preview, with a temporary TOTP factor on a staging
account:
- [x] Sign in with an MFA-enabled account, with the network log open,
landing on `/organizations`. Expect a `GET
/platform/telemetry/feature-flags` returning 200 with the account's
flags after `POST /auth/v1/factors/:id/verify`, before opening any
organization or project. Observed: flags 403 before the verify, verify
200, then one flags 200 with no organization or project param.
- [x] Repeat with `returnTo=/new`. Expect the same 200 after the verify
request. Observed: landed on `/new`, same order (403, verify 200, flags
200).
- [x] On the landing page after MFA, open the dev toolbar's Flags tab,
which reads the provider's PostHog flags. Expect the account's flags and
no `message` entry. Observed: the account's flags listed, no `message`
entry, and no flag-lookup console errors.
- [x] Sign in with an account without MFA. Expect no verify request, so
no refetch from this change. Observed: no `factors/:id/verify` request;
every flags request returned 200.
- [x] Enroll a TOTP factor in Account > Security. Expect one flags
request after the enrollment verify (the case the Note describes).
Observed: verify 200, then flags 200.

## Linear
- fixes GROWTH-1507
2026-11-18 16:26:38 +09:00
..