Repository navigation
fix(auth): offer no email recovery for account linking without an Email provider #2551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mastersam07
merged 2 commits into
version-10.0.1
from
fix/account-linking-recover-without-email
Nov 5, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import androidx.compose.animation.EnterTransition | |
| import androidx.compose.animation.ExitTransition | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.SideEffect | ||
| import androidx.compose.ui.Modifier | ||
|
|
@@ -47,8 +48,11 @@ import com.firebase.ui.auth.configuration.AuthUITransitions | |
| import com.firebase.ui.auth.configuration.authUIConfiguration | ||
| import com.firebase.ui.auth.configuration.auth_provider.AuthProvider | ||
| import com.firebase.ui.auth.configuration.string_provider.DefaultAuthUIStringProvider | ||
| import com.firebase.ui.auth.configuration.string_provider.LocalAuthUIStringProvider | ||
| import com.firebase.ui.auth.mfa.MfaChallengeContentState | ||
| import com.firebase.ui.auth.ui.FirebaseAuthTestTags | ||
| import com.firebase.ui.auth.ui.screens.email.EmailAuthMode | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we swap these two imports so
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in d6377db. |
||
| import com.firebase.ui.auth.ui.screens.email.EmailAuthScreen | ||
| import com.google.common.truth.Truth.assertThat | ||
| import com.google.firebase.FirebaseApp | ||
| import com.google.firebase.FirebaseOptions | ||
|
|
@@ -779,6 +783,101 @@ class FirebaseAuthScreenEmailRecoveryTest { | |
| composeTestRule.onNodeWithText(OTHER_EMAIL).assertIsDisplayed() | ||
| } | ||
|
|
||
| /** | ||
| * The recovery is gated on an Email provider being configured, not on sign-up being offered: | ||
| * linking signs in to an account that already exists, so an app that turns off new accounts | ||
| * still needs the step. | ||
| */ | ||
| @Test | ||
| fun `an account that needs linking still recovers to sign-in when sign-up is not offered`() { | ||
| start(configuration = emailAndPhoneConfiguration(isNewAccountsAllowed = false)) | ||
|
|
||
| recoverFrom(accountLinkingRequired(mock(AuthCredential::class.java))) | ||
|
|
||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.SignIn.EMAIL_FIELD).assertIsDisplayed() | ||
| composeTestRule.onNodeWithText(OTHER_EMAIL).assertIsDisplayed() | ||
| } | ||
|
|
||
| /** | ||
| * firebase/FirebaseUI-Android#2550: a provider sign-in hit an existing account, and the | ||
| * dialog's recovery opened an email step the app never configured, which crashed. Without an | ||
| * Email provider there is no step to offer, so the dialog offers none. | ||
| */ | ||
| @Test | ||
| fun `no recovery is offered for an account that needs linking when no Email provider is configured`() { | ||
| start(configuration = noEmailConfiguration()) | ||
|
|
||
| composeTestRule.runOnIdle { | ||
| authUI.updateAuthState( | ||
| AuthState.Error(accountLinkingRequired(mock(AuthCredential::class.java))) | ||
| ) | ||
| } | ||
| composeTestRule.waitForIdle() | ||
|
|
||
| composeTestRule.onNodeWithText(stringProvider.errorDialogTitle).assertExists() | ||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.ErrorRecovery.RETRY_BUTTON) | ||
| .assertDoesNotExist() | ||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.SignIn.EMAIL_FIELD).assertDoesNotExist() | ||
| } | ||
|
|
||
| /** | ||
| * The same crash reached another way: a Google sign-in collision arrives as | ||
| * `EmailAlreadyInUseException` through `AuthException.from`, and its recovery is the same | ||
| * email step the configuration cannot show. | ||
| */ | ||
| @Test | ||
| fun `no recovery is offered for an address already in use when no Email provider is configured`() { | ||
| start(configuration = noEmailConfiguration()) | ||
|
|
||
| composeTestRule.runOnIdle { | ||
| authUI.updateAuthState( | ||
| AuthState.Error( | ||
| AuthException.EmailAlreadyInUseException( | ||
| message = "already in use", | ||
| email = TYPED_EMAIL, | ||
| ) | ||
| ) | ||
| ) | ||
| } | ||
| composeTestRule.waitForIdle() | ||
|
|
||
| composeTestRule.onNodeWithText(stringProvider.errorDialogTitle).assertExists() | ||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.ErrorRecovery.RETRY_BUTTON) | ||
| .assertDoesNotExist() | ||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.SignIn.EMAIL_FIELD).assertDoesNotExist() | ||
| } | ||
|
|
||
| /** | ||
| * `EmailAuthScreen` is public, so a host can route to it with a configuration that has no | ||
| * Email provider. Rather than throwing, or leaving the user on an empty step, it reports the | ||
| * misconfiguration and asks the host to leave. | ||
| */ | ||
| @Test | ||
| fun `the email screen reports a misconfiguration and leaves without an Email provider`() { | ||
| val errors = mutableListOf<AuthException>() | ||
| var cancelled = 0 | ||
| composeTestRule.setContent { | ||
| CompositionLocalProvider(LocalAuthUIStringProvider provides stringProvider) { | ||
| EmailAuthScreen( | ||
| context = applicationContext, | ||
| configuration = noEmailConfiguration(), | ||
| authUI = authUI, | ||
| onSuccess = {}, | ||
| onError = { errors += it }, | ||
| onCancel = { cancelled++ }, | ||
| mode = EmailAuthMode.SignIn, | ||
| onNavigateToMode = { _, _ -> }, | ||
| ) | ||
| } | ||
| } | ||
| composeTestRule.waitForIdle() | ||
|
|
||
| composeTestRule.onNodeWithTag(FirebaseAuthTestTags.SignIn.EMAIL_FIELD).assertDoesNotExist() | ||
| assertThat(errors).hasSize(1) | ||
| assertThat(errors.single()).isInstanceOf(AuthException.MisconfigurationException::class.java) | ||
| assertThat(cancelled).isEqualTo(1) | ||
| } | ||
|
|
||
| /** | ||
| * The point of the recovery, and the half a landing assertion cannot see: the credential the | ||
| * failure carried has to survive the move and be linked once the password sign-in it asked for | ||
|
|
@@ -929,12 +1028,15 @@ class FirebaseAuthScreenEmailRecoveryTest { | |
| this.transitions = transitions | ||
| } | ||
|
|
||
| private fun emailAndPhoneConfiguration(): AuthUIConfiguration = authUIConfiguration { | ||
| private fun emailAndPhoneConfiguration( | ||
| isNewAccountsAllowed: Boolean = true, | ||
| ): AuthUIConfiguration = authUIConfiguration { | ||
| context = applicationContext | ||
| providers { | ||
| provider( | ||
| AuthProvider.Email( | ||
| isDisplayNameRequired = false, | ||
| isNewAccountsAllowed = isNewAccountsAllowed, | ||
| emailLinkActionCodeSettings = null, | ||
| passwordValidationRules = emptyList() | ||
| ) | ||
|
|
@@ -950,6 +1052,25 @@ class FirebaseAuthScreenEmailRecoveryTest { | |
| isCredentialManagerEnabled = false | ||
| } | ||
|
|
||
| /** | ||
| * Two providers and neither is Email, so the flow opens on the method picker: where a | ||
| * provider sign-in such as Facebook raises its account-linking failure. | ||
| */ | ||
| private fun noEmailConfiguration(): AuthUIConfiguration = authUIConfiguration { | ||
| context = applicationContext | ||
| providers { | ||
| provider(AuthProvider.Anonymous) | ||
| provider( | ||
| AuthProvider.Phone( | ||
| defaultNumber = null, | ||
| defaultCountryCode = null, | ||
| allowedCountries = null | ||
| ) | ||
| ) | ||
| } | ||
| isCredentialManagerEnabled = false | ||
| } | ||
|
|
||
| private fun recordingTransitions(into: MutableList<String>) = AuthUITransitions( | ||
| transitionSpec = { | ||
| into += "transition:${label()}" | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
EmailAlreadyInUseExceptionjust above get the sameisEmailProviderConfigured()check? A Google sign-in collision lands there throughAuthException.from, and it still opens the email step. Happy for this to be a follow-up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d6377db, with a test for the address-in-use path when no Email provider is configured.