Repository navigation
Conversation
Reauthenticating a user with enrolled second factors threw secondFactorRequired from user.reauthenticate(with:). The reauth views passed it to reportError, whose alert sits behind the reauth sheet, so tapping Confirm did nothing visible. AuthService now catches secondFactorRequired during reauthentication, keeps the MultiFactorResolver and throws AuthServiceError.multiFactorReauthenticationRequired(MFARequired), so the factor is resolved with resolveSmsChallenge and resolveSignIn as for sign-in. The email, phone and email link reauth sheets push MFAResolutionView inside the sheet, OAuth reauth presents it in its own sheet, and reauth sheets show errors in place instead of behind the sheet.
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for Multi-Factor Authentication (MFA) during reauthentication in FirebaseAuthSwiftUI by introducing a new multiFactorReauthenticationRequired error, updating AuthService to capture the MFA resolver, and integrating the MFA resolution flow into the reauthentication views and coordinator. Feedback on these changes highlights a compiler error in AuthService.swift due to incorrect pattern matching on an existential Error type, a potential leak of CheckedContinuation when other reauthentication sheets are dismissed without onDismiss handlers, and a potential memory leak of MultiFactorResolver if the MFA flow is cancelled or fails without clearing currentMFAResolver.
demolaf
marked this pull request as draft
October 22, 2026 09:52
The phone, email and email link reauth sheets had no onDismiss, so swiping one away left the requestReauth continuation pending and the caller waiting forever. They now cancel reauthentication on dismiss, as the MFA reauth sheet already does. signOut also clears any stored MFA resolver so it does not outlive the session.
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.
Resolves the second factor when reauthenticating an MFA-enrolled user. Previously tapping Confirm in the reauth sheet did nothing visible, because the secondFactorRequired error was reported to an alert behind the sheet.
AuthServiceError.multiFactorReauthenticationRequired(MFARequired), so exhaustiveswitches overAuthServiceErrorneed a new case.reauthenticate(with:)andreauthenticate(context:)throw it instead of the rawsecondFactorRequirederror.Changes
AuthServicekeeps theMultiFactorResolverfrom reauthentication, soresolveSmsChallengeandresolveSignIncomplete it as they do for sign-in.MFAResolutionViewinside the sheet, and OAuth reauth presents it in its own sheet.MFAResolutionViewgains a keyboard Done button so the number pad no longer hides its actions.signOut()clears the stored MFA resolver.resolveSignInitself is not asserted because the emulator rejects it (MFA_ENROLLMENT_NOT_FOUND on MFA when using Firebase Auth Emulator firebase-ios-sdk#11079).Preview
Expected: when a user wants to remove a second factor and is asked to reauthenticate, entering the correct password should take them to the second-factor step so they can finish confirming it is them.
Before (
main): nothing happens.mfa-reauth-before.mp4
After (this branch): the second-factor step opens in the sheet.
mfa-reauth-after.mp4
Maintainer note: Fixes internal CPRN-593