Skip to content

fix(auth): don't strand phone-only users on email verification after reload - #2474

Merged
demolaf merged 1 commit into
version-10.0.0-beta05from
fix/reload-user-email-verification
Sep 3, 2026
Merged

fix(auth): don't strand phone-only users on email verification after reload#2474
demolaf merged 1 commit into
version-10.0.0-beta05from
fix/reload-user-email-verification

Conversation

@demolaf

@demolaf demolaf commented Sep 3, 2026

Copy link
Copy Markdown
Member

onReloadUser on AuthSuccessUiContext re-derived "does this user need email verification?" from isEmailVerified alone, dropping the email != null and password-provider checks FirebaseAuthUI already applied. A phone-only user is unverified and has no email, so any authenticatedContent slot calling uiContext.onReloadUser() published RequiresEmailVerification(email = "") — and because authStateFlow() prefers any non-Idle internal state, it stuck there with signing out the only exit. Latent in the stock UI, which wires the callback only to its own verify-email screen.

Deriving auth state isn't the screen's job, so the reload moves to FirebaseAuthUI.reloadUser() and reuses the existing handleAuthUserState rule rather than duplicating it. It also revalidates the current user after its two suspension points: signing out mid-reload previously published Success for the departed user, made permanent by that same precedence. The screen keeps only the error logging, and now rethrows CancellationException instead of logging it as a refresh failure.

Tests go in FirebaseAuthUIAuthStateTest — phone-only, federated, unverified password, and sign-out mid-reload. Verified by mutation rather than assumed: reinstating the old derivation reds the first two, and dropping the revalidation reds the last.


Maintainer note: Fixes internal CPRN-407

@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 stable test tags (FirebaseAuthTestTags) and exposes them as Android resource IDs to support automated testing with Firebase Test Lab and Robo. It also improves accessibility by adding positional content descriptions to verification code digit boxes and declaring text-input semantics on the digit group to allow crawlers to input verification codes in a single action. Additionally, recovery codes have been completely removed from the Multi-Factor Authentication (MFA) flow across all configurations, UI screens, and localized string resources. Other changes include diagnostic logging for Google Sign-In failures, improved modifier propagation, and comprehensive unit tests validating these updates. I have no feedback to provide as there are no review comments.

@demolaf
demolaf force-pushed the fix/reload-user-email-verification branch 4 times, most recently from a079274 to 3abf81a Compare September 3, 2026 08:33

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The split derivation was the bug, and putting reload behind handleAuthUserState is the right fix.

Two nits, neither blocking:

The unverified-password test does not pin republish the way the other two do. Phone-only and federated call pinToEmailVerification() first, so they fail unless reloadUser() overwrites the stuck internal state. The password test starts from Idle, and authStateFlow() would already emit RequiresEmailVerification from the Firebase listener even if reloadUser() never called updateAuthState. Pinning with email = "" first, then asserting it becomes "test@example.com", would make that test do the same job.

The sign-out-mid-reload test stubs getIdToken(true) to succeed, so the uid check is what saves it. In production, signing out during reload() is more likely to make getIdToken throw, which the screen logs as "Failed to refresh user" before that check runs. I don't think that re-strands anyone: the AuthStateListener already clears stale RequiresEmailVerification / Success on sign-out. An extra uid check between the two awaits would just avoid the misleading log.

@demolaf
demolaf force-pushed the fix/reload-user-email-verification branch from 3abf81a to 2f12e3d Compare September 3, 2026 13:18
@demolaf
demolaf merged commit df1ef1b into version-10.0.0-beta05 Sep 3, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Sep 3, 2026
@demolaf
demolaf deleted the fix/reload-user-email-verification branch September 3, 2026 13:38
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.

2 participants