Skip to content

Commit d276b8e

Browse files
authored
Add more logging when buildCredential fails (#1763)
1 parent 94539e3 commit d276b8e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

auth/src/main/java/com/firebase/ui/auth/util/CredentialUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.net.Uri;
44
import android.text.TextUtils;
5+
import android.util.Log;
56

67
import com.firebase.ui.auth.IdpResponse;
78
import com.google.android.gms.auth.api.credentials.Credential;
@@ -16,6 +17,9 @@
1617
*/
1718
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1819
public class CredentialUtils {
20+
21+
private static final String TAG = "CredentialUtils";
22+
1923
private CredentialUtils() {
2024
throw new AssertionError("No instance for you!");
2125
}
@@ -35,8 +39,14 @@ public static Credential buildCredential(@NonNull FirebaseUser user,
3539
Uri profilePictureUri =
3640
user.getPhotoUrl() == null ? null : Uri.parse(user.getPhotoUrl().toString());
3741

38-
if (TextUtils.isEmpty(email) && TextUtils.isEmpty(phone)) { return null; }
39-
if (password == null && accountType == null) { return null; }
42+
if (TextUtils.isEmpty(email) && TextUtils.isEmpty(phone)) {
43+
Log.w(TAG, "User (accountType=" + accountType + ") has no email or phone number, cannot build credential.");
44+
return null;
45+
}
46+
if (password == null && accountType == null) {
47+
Log.w(TAG, "User has no accountType or password, cannot build credential.");
48+
return null;
49+
}
4050

4151
Credential.Builder builder =
4252
new Credential.Builder(TextUtils.isEmpty(email) ? phone : email)

0 commit comments

Comments
 (0)