Search in sources :

Example 31 with FirebaseAuth

use of com.google.firebase.auth.FirebaseAuth in project FirebaseUI-Android by firebase.

the class AuthUiActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    FirebaseAuth auth = FirebaseAuth.getInstance();
    if (auth.getCurrentUser() != null && getIntent().getExtras() == null) {
        startSignedInActivity(null);
        finish();
    }
}
Also used : FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 32 with FirebaseAuth

use of com.google.firebase.auth.FirebaseAuth in project FirebaseUI-Android by firebase.

the class GenericIdpSignInHandler method handleNormalSignInFlow.

protected void handleNormalSignInFlow(final FirebaseAuth auth, final HelperActivityBase activity, final OAuthProvider provider) {
    final boolean useEmulator = activity.getAuthUI().isUseEmulator();
    auth.startActivityForSignInWithProvider(activity, provider).addOnSuccessListener(authResult -> handleSuccess(useEmulator, provider.getProviderId(), authResult.getUser(), (OAuthCredential) authResult.getCredential(), authResult.getAdditionalUserInfo().isNewUser())).addOnFailureListener(e -> {
        if (e instanceof FirebaseAuthException) {
            FirebaseAuthError error = FirebaseAuthError.fromException((FirebaseAuthException) e);
            if (e instanceof FirebaseAuthUserCollisionException) {
                FirebaseAuthUserCollisionException collisionException = (FirebaseAuthUserCollisionException) e;
                setResult(Resource.forFailure(new FirebaseUiUserCollisionException(ErrorCodes.ERROR_GENERIC_IDP_RECOVERABLE_ERROR, "Recoverable error.", provider.getProviderId(), collisionException.getEmail(), collisionException.getUpdatedCredential())));
            } else if (error == FirebaseAuthError.ERROR_WEB_CONTEXT_CANCELED) {
                setResult(Resource.forFailure(new UserCancellationException()));
            } else {
                setResult(Resource.forFailure(e));
            }
        } else {
            setResult(Resource.forFailure(e));
        }
    });
}
Also used : ProviderUtils(com.firebase.ui.auth.util.data.ProviderUtils) NonNull(androidx.annotation.NonNull) User(com.firebase.ui.auth.data.model.User) Intent(android.content.Intent) Resource(com.firebase.ui.auth.data.model.Resource) ExtraConstants(com.firebase.ui.auth.util.ExtraConstants) HashMap(java.util.HashMap) FirebaseUiUserCollisionException(com.firebase.ui.auth.FirebaseUiUserCollisionException) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) GoogleAuthProvider(com.google.firebase.auth.GoogleAuthProvider) OAuthCredential(com.google.firebase.auth.OAuthCredential) RestrictTo(androidx.annotation.RestrictTo) OnFailureListener(com.google.android.gms.tasks.OnFailureListener) AuthUI(com.firebase.ui.auth.AuthUI) R(com.firebase.ui.auth.R) FirebaseAuth(com.google.firebase.auth.FirebaseAuth) FirebaseAuthUserCollisionException(com.google.firebase.auth.FirebaseAuthUserCollisionException) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) HelperActivityBase(com.firebase.ui.auth.ui.HelperActivityBase) FirebaseUser(com.google.firebase.auth.FirebaseUser) AuthOperationManager(com.firebase.ui.auth.util.data.AuthOperationManager) FacebookAuthProvider(com.google.firebase.auth.FacebookAuthProvider) FirebaseAuthError(com.firebase.ui.auth.util.FirebaseAuthError) OAuthProvider(com.google.firebase.auth.OAuthProvider) AuthCredential(com.google.firebase.auth.AuthCredential) FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) List(java.util.List) Nullable(androidx.annotation.Nullable) Application(android.app.Application) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) OnSuccessListener(com.google.android.gms.tasks.OnSuccessListener) FirebaseAuthException(com.google.firebase.auth.FirebaseAuthException) ProviderSignInBase(com.firebase.ui.auth.viewmodel.ProviderSignInBase) RequestCodes(com.firebase.ui.auth.viewmodel.RequestCodes) AuthResult(com.google.firebase.auth.AuthResult) ErrorCodes(com.firebase.ui.auth.ErrorCodes) VisibleForTesting(androidx.annotation.VisibleForTesting) IdpResponse(com.firebase.ui.auth.IdpResponse) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) FirebaseAuthError(com.firebase.ui.auth.util.FirebaseAuthError) FirebaseAuthUserCollisionException(com.google.firebase.auth.FirebaseAuthUserCollisionException) FirebaseAuthException(com.google.firebase.auth.FirebaseAuthException) FirebaseUiUserCollisionException(com.firebase.ui.auth.FirebaseUiUserCollisionException)

Aggregations

FirebaseAuth (com.google.firebase.auth.FirebaseAuth)32 FirebaseUser (com.google.firebase.auth.FirebaseUser)20 Intent (android.content.Intent)11 DataSnapshot (com.google.firebase.database.DataSnapshot)8 DatabaseError (com.google.firebase.database.DatabaseError)8 View (android.view.View)7 ValueEventListener (com.google.firebase.database.ValueEventListener)7 AuthResult (com.google.firebase.auth.AuthResult)6 IdpResponse (com.firebase.ui.auth.IdpResponse)5 FirebaseAuthUserCollisionException (com.google.firebase.auth.FirebaseAuthUserCollisionException)5 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)4 NonNull (androidx.annotation.NonNull)3 Nullable (androidx.annotation.Nullable)3 RestrictTo (androidx.annotation.RestrictTo)3 AuthCredential (com.google.firebase.auth.AuthCredential)3 Application (android.app.Application)2 Bundle (android.os.Bundle)2 TextView (android.widget.TextView)2 FacebookException (com.facebook.FacebookException)2 LoginResult (com.facebook.login.LoginResult)2