use of com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER in project FirebaseUI-Android by firebase.
the class EmailLinkSignInHandler method handleNormalFlow.
private void handleNormalFlow(final AuthOperationManager authOperationManager, final EmailLinkPersistenceManager persistenceManager, final String email, final String link) {
final AuthCredential emailLinkCredential = EmailAuthProvider.getCredentialWithLink(email, link);
// Bug in core SDK - credential is mutated and won't be usable for sign in, so create
// a new one to pass back. b/117425827
final AuthCredential emailLinkCredentialForLinking = EmailAuthProvider.getCredentialWithLink(email, link);
// Either regular sign in or anonymous user upgrade
authOperationManager.signInAndLinkWithCredential(getAuth(), getArguments(), emailLinkCredential).addOnSuccessListener(authResult -> {
persistenceManager.clearAllData(getApplication());
FirebaseUser user = authResult.getUser();
IdpResponse response = new IdpResponse.Builder(new User.Builder(EMAIL_LINK_PROVIDER, user.getEmail()).setName(user.getDisplayName()).setPhotoUri(user.getPhotoUrl()).build()).build();
handleSuccess(response, authResult);
}).addOnFailureListener(e -> {
persistenceManager.clearAllData(getApplication());
if (e instanceof FirebaseAuthUserCollisionException) {
handleMergeFailure(emailLinkCredentialForLinking);
} else {
setResult(Resource.forFailure(e));
}
});
}
Aggregations