Skip to content

Commit

Permalink
Warn instead of crashing on reserved email (#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern authored Jul 21, 2020
1 parent ce8426a commit c85355c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixes issue with custom parameters for OAuth providers (#1805)
- Restore `setGithubButtonId` when using custom layouts (#1783)
- Improve how network errors display when they are non-fatal (#1803)
- Warn instead of crashing when a reserved email is used (#1644)
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.firebase.ui.auth.viewmodel.email;

import android.app.Application;
import android.util.Log;

import com.firebase.ui.auth.ErrorCodes;
import com.firebase.ui.auth.FirebaseUiException;
import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.data.model.IntentRequiredException;
import com.firebase.ui.auth.data.model.Resource;
Expand All @@ -23,6 +26,7 @@
import com.google.firebase.auth.FirebaseAuthUserCollisionException;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

import static com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER;
Expand Down Expand Up @@ -70,6 +74,8 @@ public void onFailure(@NonNull Exception e) {
password);
handleMergeFailure(credential);
} else {
Log.w(TAG, "Got a collision error during a non-upgrade flow", e);

// Collision with existing user email without anonymous upgrade
// it should be very hard for the user to even get to this error
// due to CheckEmailFragment.
Expand Down Expand Up @@ -97,10 +103,14 @@ public StartWelcomeBackFlow(String email) {
}

@Override
public void onSuccess(String provider) {
public void onSuccess(@Nullable String provider) {
if (provider == null) {
throw new IllegalStateException(
"User has no providers even though we got a collision.");
Log.w(TAG, "No providers known for user ("
+ mEmail
+ ") this email address may be reserved.");
setResult(Resource.<IdpResponse>forFailure(
new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR)));
return;
}

if (EmailAuthProvider.PROVIDER_ID.equalsIgnoreCase(provider)) {
Expand Down

0 comments on commit c85355c

Please sign in to comment.