Skip to content

Commit c85355c

Browse files
authored
Warn instead of crashing on reserved email (#1812)
1 parent ce8426a commit c85355c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- Fixes issue with custom parameters for OAuth providers (#1805)
22
- Restore `setGithubButtonId` when using custom layouts (#1783)
33
- Improve how network errors display when they are non-fatal (#1803)
4+
- Warn instead of crashing when a reserved email is used (#1644)

auth/src/main/java/com/firebase/ui/auth/viewmodel/email/EmailProviderResponseHandler.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.firebase.ui.auth.viewmodel.email;
22

33
import android.app.Application;
4+
import android.util.Log;
45

6+
import com.firebase.ui.auth.ErrorCodes;
7+
import com.firebase.ui.auth.FirebaseUiException;
58
import com.firebase.ui.auth.IdpResponse;
69
import com.firebase.ui.auth.data.model.IntentRequiredException;
710
import com.firebase.ui.auth.data.model.Resource;
@@ -23,6 +26,7 @@
2326
import com.google.firebase.auth.FirebaseAuthUserCollisionException;
2427

2528
import androidx.annotation.NonNull;
29+
import androidx.annotation.Nullable;
2630
import androidx.annotation.RestrictTo;
2731

2832
import static com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER;
@@ -70,6 +74,8 @@ public void onFailure(@NonNull Exception e) {
7074
password);
7175
handleMergeFailure(credential);
7276
} else {
77+
Log.w(TAG, "Got a collision error during a non-upgrade flow", e);
78+
7379
// Collision with existing user email without anonymous upgrade
7480
// it should be very hard for the user to even get to this error
7581
// due to CheckEmailFragment.
@@ -97,10 +103,14 @@ public StartWelcomeBackFlow(String email) {
97103
}
98104

99105
@Override
100-
public void onSuccess(String provider) {
106+
public void onSuccess(@Nullable String provider) {
101107
if (provider == null) {
102-
throw new IllegalStateException(
103-
"User has no providers even though we got a collision.");
108+
Log.w(TAG, "No providers known for user ("
109+
+ mEmail
110+
+ ") this email address may be reserved.");
111+
setResult(Resource.<IdpResponse>forFailure(
112+
new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR)));
113+
return;
104114
}
105115

106116
if (EmailAuthProvider.PROVIDER_ID.equalsIgnoreCase(provider)) {

0 commit comments

Comments
 (0)