Skip to content

fix(auth): reset MfaEnrollmentScreen to a clean flow after successful enrollment - #2463

Open
demolaf wants to merge 1 commit into
feat/mfa-enrollment-testfrom
fix/mfa-enrollment-reset-after-complete
Open

fix(auth): reset MfaEnrollmentScreen to a clean flow after successful enrollment#2463
demolaf wants to merge 1 commit into
feat/mfa-enrollment-testfrom
fix/mfa-enrollment-reset-after-complete

Conversation

@demolaf

@demolaf demolaf commented Sep 1, 2026

Copy link
Copy Markdown
Member

After a successful enrollment MfaEnrollmentScreen invoked onComplete() but left currentStep on VerifyFactor with verificationCode still populated, so a caller embedding the screen directly and not navigating away sat on a filled form whose Verify button re-submitted an already-consumed code. FirebaseAuthScreen pops the back stack on completion, which is why this never surfaced through the default host.

The screen now resets to SelectFactor and clears all consumed input before invoking onComplete. A latch on the single-factor auto-advance stops a configuration change after success from restoring the reset step and immediately re-entering enrollment for a factor the user already has. FirebaseAuthScreen retains the completed state for the duration of its exit transition, so the destination no longer turns into the factor picker mid-fade.

Added tests covering the reset on the SMS and TOTP paths, the latch across a state restoration, and the destination retention — each verified to fail against the unfixed code.


Maintainer note: Fixes internal CPRN-384

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a state reset mechanism to the MFA enrollment screen upon successful enrollment, resetting it back to the SelectFactor step and clearing consumed inputs before invoking onComplete. To prevent the UI from prematurely resetting during the back-stack pop transition, a MfaEnrollmentDestination wrapper with a RetainedMfaEnrollmentState has been introduced to freeze and retain the completed state during the transition. Additionally, single-factor auto-advance is now suppressed after a completed enrollment to avoid re-triggering the flow upon state restoration. Comprehensive unit tests have been added to verify these behaviors. I have no feedback to provide as there are no review comments.

@demolaf
demolaf force-pushed the fix/mfa-enrollment-reset-after-complete branch from ab4f6dd to f3f02fd Compare September 1, 2026 15:48
@demolaf
demolaf force-pushed the fix/mfa-enrollment-reset-after-complete branch from f3f02fd to ce24ffa Compare September 1, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant