Skip to content

Fixing isNewUser #1832

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
merged 2 commits into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ protected void handleNormalSignInFlow(final FirebaseAuth auth,
@Override
public void onSuccess(@NonNull AuthResult authResult) {
handleSuccess(provider.getProviderId(),
authResult.getUser(), (OAuthCredential)
authResult.getCredential());
authResult.getUser(),
(OAuthCredential) authResult.getCredential(),
authResult.getAdditionalUserInfo().isNewUser());
}
})
.addOnFailureListener(
Expand Down Expand Up @@ -135,8 +136,9 @@ private void handleAnonymousUpgradeFlow(final FirebaseAuth auth,
@Override
public void onSuccess(@NonNull AuthResult authResult) {
handleSuccess(provider.getProviderId(),
authResult.getUser(), (OAuthCredential)
authResult.getCredential());
authResult.getUser(),
(OAuthCredential) authResult.getCredential(),
authResult.getAdditionalUserInfo().isNewUser());
}
})
.addOnFailureListener(
Expand Down Expand Up @@ -221,6 +223,7 @@ protected OAuthProvider buildOAuthProvider(String providerId) {
protected void handleSuccess(@NonNull String providerId,
@NonNull FirebaseUser user,
@NonNull OAuthCredential credential,
boolean isNewUser,
boolean setPendingCredential) {
IdpResponse.Builder response = new IdpResponse.Builder(
new User.Builder(
Expand All @@ -234,14 +237,16 @@ protected void handleSuccess(@NonNull String providerId,
if (setPendingCredential) {
response.setPendingCredential(credential);
}
response.setNewUser(isNewUser);

setResult(Resource.<IdpResponse>forSuccess(response.build()));
}

protected void handleSuccess(@NonNull String providerId,
@NonNull FirebaseUser user,
@NonNull OAuthCredential credential) {
handleSuccess(providerId, user, credential, /* setPendingCredential= */false);
@NonNull OAuthCredential credential,
boolean isNewUser) {
handleSuccess(providerId, user, credential, isNewUser, /* setPendingCredential= */true);
}


Expand Down