feat(auth-machine): auth state machine for sign-in, sign-up and reset with feature flag#20775
Draft
vbudhram wants to merge 1 commit into
Draft
feat(auth-machine): auth state machine for sign-in, sign-up and reset with feature flag#20775vbudhram wants to merge 1 commit into
vbudhram wants to merge 1 commit into
Conversation
…p and reset Because: - Post-authentication navigation was scattered across leaf handlers, making routing hard to reason about and inconsistent across integration types (plain web, Sync, Firefox-non-sync, OAuth web, OAuth native). This commit: - Adds a hand-rolled funnel state machine (funnelReducer) plus pure routing functions that own the post-auth destination decision, while legacy leaf handlers keep performing the side effects (no double execution). - Gates all behavior behind a tri-state authStateMachine override (?authStateMachine=true|false forces on/off, absent falls back to config). - Routes sign-in, post-signup-confirmation, reset-password (post-OTP decision, recovery-choice, completion handoff), the Settings AAL2 access guard and the InlineTotpSetup post-setup redirect through the machine. - Adds exhaustive Playwright E2E coverage under tests/authMachine/ spanning all integration types for sign-in, sign-up, reset, TOTP, unblock (FXA-12084), the AAL2 guard and the off-switch, plus unit coverage of the routing rules. - Makes the TOTP-setup page-object helper recovery-phone-availability aware so the recovery-method chooser is skipped when it is unavailable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because
This pull request
funnelReducer+ pure routing functions underlib/auth-machine/) that owns the post-auth destination; legacy leaf handlers keep performing side effects, so nothing double-executes.authStateMachineoverride viaflag.ts(?authStateMachine=true|falseforces on/off; otherwise the config flag decides).ConfirmSignupCode), reset-password, the Settings AAL2 access guard, andInlineTotpSetupthrough the machine inSignin/utils.ts(handleNavigation).Signin/index.tsx(flag- and verify-gated, with a fallback so it never blocks sign-in).tests/authMachine/(sign-in/up across every integration type, reset, TOTP, unblock/FXA-12084, AAL2 guard, off-switch) plus unit coverage of every routing rule.flowchart TD A[Auth result: sign-in / sign-up / reset] --> B{authStateMachine enabled?} B -- "off / ?authStateMachine=false" --> L[Legacy leaf handlers - unchanged] B -- "on / config / ?authStateMachine=true" --> M[funnelReducer - routing brain] M --> R{routeAfterVerify} R -- "emailVerified AND sessionVerified" --> H[finalizing.handoff: /settings, Sync CAD, OAuth RP redirect] R -- "accountHasTotp OR method=totp-2fa" --> T[verifying.totp: /signin_totp_code] R -- "!emailVerified OR reason=SIGN_UP" --> D[delegated.legacy: /confirm_signup_code] R -- "session unverified" --> E[verifying.emailTokenCode: /signin_token_code] M -. "side effects unchanged" .-> S[sendFxaLogin · finishOAuthFlow · fxaOAuthLogin]Issue that this pull request solves
Closes:
Checklist
Other information
How to test:
?authStateMachine=trueto any sign-in URL (e.g./signin?authStateMachine=true).?authStateMachine=falseforces legacy.