Java Code Examples for com.firebase.ui.auth.ErrorCodes#ANONYMOUS_UPGRADE_MERGE_CONFLICT

The following examples show how to use com.firebase.ui.auth.ErrorCodes#ANONYMOUS_UPGRADE_MERGE_CONFLICT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnonymousUpgradeActivity.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);
        if (response == null) {
            // User pressed back button
            return;
        }
        if (resultCode == RESULT_OK) {
            setStatus("Signed in as " + getUserIdentifier(FirebaseAuth.getInstance()
                    .getCurrentUser()));
        } else if (response.getError().getErrorCode() == ErrorCodes
                .ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
            setStatus("Merge conflict: user already exists.");
            mResolveMergeButton.setEnabled(true);
            mPendingCredential = response.getCredentialForLinking();
        } else {
            Toast.makeText(this, "Auth error, see logs", Toast.LENGTH_SHORT).show();
            Log.w(TAG, "Error: " + response.getError().getMessage(), response.getError());
        }

        updateUI();
    }
}
 
Example 2
Source File: AuthUiActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void handleSignInResponse(int resultCode, @Nullable Intent data) {
    IdpResponse response = IdpResponse.fromResultIntent(data);

    // Successfully signed in
    if (resultCode == RESULT_OK) {
        startSignedInActivity(response);
        finish();
    } else {
        // Sign in failed
        if (response == null) {
            // User pressed back button
            showSnackbar(R.string.sign_in_cancelled);
            return;
        }

        if (response.getError().getErrorCode() == ErrorCodes.NO_NETWORK) {
            showSnackbar(R.string.no_internet_connection);
            return;
        }

        if (response.getError().getErrorCode() == ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
            Intent intent = new Intent(this, AnonymousUpgradeActivity.class).putExtra
                    (ExtraConstants.IDP_RESPONSE, response);
            startActivity(intent);
        }

        if (response.getError().getErrorCode() == ErrorCodes.ERROR_USER_DISABLED) {
            showSnackbar(R.string.account_disabled);
            return;
        }

        showSnackbar(R.string.unknown_error);
        Log.e(TAG, "Sign-in error: ", response.getError());
    }
}
 
Example 3
Source File: SignInKickstarter.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    switch (requestCode) {
        case RequestCodes.CRED_HINT:
            if (resultCode == Activity.RESULT_OK) {
                handleCredential((Credential) data.getParcelableExtra(Credential.EXTRA_KEY));
            } else {
                startAuthMethodChoice();
            }
            break;
        case RequestCodes.EMAIL_FLOW:
        case RequestCodes.AUTH_PICKER_FLOW:
        case RequestCodes.PHONE_FLOW:
        case RequestCodes.PROVIDER_FLOW:
            if (resultCode == RequestCodes.EMAIL_LINK_WRONG_DEVICE_FLOW || resultCode == RequestCodes.EMAIL_LINK_INVALID_LINK_FLOW) {
                startAuthMethodChoice();
                return;
            }
            IdpResponse response = IdpResponse.fromResultIntent(data);
            if (response == null) {
                setResult(Resource.<IdpResponse>forFailure(new UserCancellationException()));
            } else if (response.isSuccessful()) {
                setResult(Resource.forSuccess(response));
            } else if (response.getError().getErrorCode() ==
                    ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
                handleMergeFailure(response);
            } else {
                setResult(Resource.<IdpResponse>forFailure(response.getError()));
            }
    }
}
 
Example 4
Source File: EmailSignInHandler.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (resultCode == ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
        // The activity deals with this case. This conflict is handled by the developer.
    } else if (requestCode == RequestCodes.EMAIL_FLOW) {
        IdpResponse response = IdpResponse.fromResultIntent(data);
        if (response == null) {
            setResult(Resource.<IdpResponse>forFailure(new UserCancellationException()));
        } else {
            setResult(Resource.forSuccess(response));
        }
    }
}
 
Example 5
Source File: HelperActivityBase.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Forward the results of Smart Lock saving
    if (requestCode == RequestCodes.CRED_SAVE_FLOW
            || resultCode == ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT) {
        finish(resultCode, data);
    }
}