Search in sources :

Example 1 with EMAIL_LINK_PROVIDER

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));
        }
    });
}
Also used : AuthCredential(com.google.firebase.auth.AuthCredential) ActionCodeResult(com.google.firebase.auth.ActionCodeResult) ProviderUtils(com.firebase.ui.auth.util.data.ProviderUtils) ProfileMerger(com.firebase.ui.auth.data.remote.ProfileMerger) EMAIL_LINK_PROVIDER(com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER) NonNull(androidx.annotation.NonNull) User(com.firebase.ui.auth.data.model.User) EmailLinkPersistenceManager(com.firebase.ui.auth.util.data.EmailLinkPersistenceManager) Resource(com.firebase.ui.auth.data.model.Resource) EmailLinkParser(com.firebase.ui.auth.util.data.EmailLinkParser) TaskFailureLogger(com.firebase.ui.auth.util.data.TaskFailureLogger) Task(com.google.android.gms.tasks.Task) OnFailureListener(com.google.android.gms.tasks.OnFailureListener) Continuation(com.google.android.gms.tasks.Continuation) FirebaseAuthUserCollisionException(com.google.firebase.auth.FirebaseAuthUserCollisionException) SignInViewModelBase(com.firebase.ui.auth.viewmodel.SignInViewModelBase) FirebaseUser(com.google.firebase.auth.FirebaseUser) SessionRecord(com.firebase.ui.auth.util.data.EmailLinkPersistenceManager.SessionRecord) TextUtils(android.text.TextUtils) AuthOperationManager(com.firebase.ui.auth.util.data.AuthOperationManager) OnCompleteListener(com.google.android.gms.tasks.OnCompleteListener) AuthCredential(com.google.firebase.auth.AuthCredential) Nullable(androidx.annotation.Nullable) EmailAuthProvider(com.google.firebase.auth.EmailAuthProvider) Application(android.app.Application) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) OnSuccessListener(com.google.android.gms.tasks.OnSuccessListener) AuthResult(com.google.firebase.auth.AuthResult) ErrorCodes(com.firebase.ui.auth.ErrorCodes) IdpResponse(com.firebase.ui.auth.IdpResponse) FirebaseAuthUserCollisionException(com.google.firebase.auth.FirebaseAuthUserCollisionException) FirebaseUser(com.google.firebase.auth.FirebaseUser) IdpResponse(com.firebase.ui.auth.IdpResponse)

Aggregations

Application (android.app.Application)1 TextUtils (android.text.TextUtils)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 EMAIL_LINK_PROVIDER (com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER)1 ErrorCodes (com.firebase.ui.auth.ErrorCodes)1 FirebaseUiException (com.firebase.ui.auth.FirebaseUiException)1 IdpResponse (com.firebase.ui.auth.IdpResponse)1 Resource (com.firebase.ui.auth.data.model.Resource)1 User (com.firebase.ui.auth.data.model.User)1 ProfileMerger (com.firebase.ui.auth.data.remote.ProfileMerger)1 AuthOperationManager (com.firebase.ui.auth.util.data.AuthOperationManager)1 EmailLinkParser (com.firebase.ui.auth.util.data.EmailLinkParser)1 EmailLinkPersistenceManager (com.firebase.ui.auth.util.data.EmailLinkPersistenceManager)1 SessionRecord (com.firebase.ui.auth.util.data.EmailLinkPersistenceManager.SessionRecord)1 ProviderUtils (com.firebase.ui.auth.util.data.ProviderUtils)1 TaskFailureLogger (com.firebase.ui.auth.util.data.TaskFailureLogger)1 SignInViewModelBase (com.firebase.ui.auth.viewmodel.SignInViewModelBase)1 Continuation (com.google.android.gms.tasks.Continuation)1 OnCompleteListener (com.google.android.gms.tasks.OnCompleteListener)1