Search in sources :

Example 1 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class CheckPhoneNumberFragment method setupPrivacyDisclosures.

private void setupPrivacyDisclosures() {
    FlowParameters params = getFlowParams();
    boolean termsAndPrivacyUrlsProvided = params.isTermsOfServiceUrlProvided() && params.isPrivacyPolicyUrlProvided();
    if (!params.shouldShowProviderChoice() && termsAndPrivacyUrlsProvided) {
        PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicySmsText(requireContext(), params, mSmsTermsText);
    } else {
        PrivacyDisclosureUtils.setupTermsOfServiceFooter(requireContext(), params, mFooterText);
        String verifyText = getString(R.string.fui_verify_phone_number);
        mSmsTermsText.setText(getString(R.string.fui_sms_terms_of_service, verifyText));
    }
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters)

Example 2 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class GenericIdpSignInHandler method handleAnonymousUpgradeFlow.

private void handleAnonymousUpgradeFlow(final FirebaseAuth auth, final HelperActivityBase activity, final OAuthProvider provider, final FlowParameters flowParameters) {
    final boolean useEmulator = activity.getAuthUI().isUseEmulator();
    auth.getCurrentUser().startActivityForLinkWithProvider(activity, provider).addOnSuccessListener(authResult -> handleSuccess(useEmulator, provider.getProviderId(), authResult.getUser(), (OAuthCredential) authResult.getCredential(), authResult.getAdditionalUserInfo().isNewUser())).addOnFailureListener(e -> {
        if (!(e instanceof FirebaseAuthUserCollisionException)) {
            setResult(Resource.forFailure(e));
            return;
        }
        FirebaseAuthUserCollisionException collisionException = (FirebaseAuthUserCollisionException) e;
        final AuthCredential credential = collisionException.getUpdatedCredential();
        final String email = collisionException.getEmail();
        // Case 1: Anonymous user trying to link with an existing user
        // Case 2: Anonymous user trying to link with a provider keyed
        // by an email that already belongs to an existing account
        // (linking flow)
        ProviderUtils.fetchSortedProviders(auth, flowParameters, email).addOnSuccessListener(providers -> {
            if (providers.isEmpty()) {
                String errorMessage = "Unable to complete the linkingflow -" + " the user is using " + "unsupported providers.";
                setResult(Resource.forFailure(new FirebaseUiException(ErrorCodes.DEVELOPER_ERROR, errorMessage)));
                return;
            }
            if (providers.contains(provider.getProviderId())) {
                // Case 1
                handleMergeFailure(credential);
            } else {
                // Case 2 - linking flow to be handled by
                // SocialProviderResponseHandler
                setResult(Resource.forFailure(new FirebaseUiUserCollisionException(ErrorCodes.ERROR_GENERIC_IDP_RECOVERABLE_ERROR, "Recoverable error.", provider.getProviderId(), email, credential)));
            }
        });
    });
}
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) OAuthCredential(com.google.firebase.auth.OAuthCredential) AuthCredential(com.google.firebase.auth.AuthCredential) FirebaseAuthUserCollisionException(com.google.firebase.auth.FirebaseAuthUserCollisionException) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) FirebaseUiUserCollisionException(com.firebase.ui.auth.FirebaseUiUserCollisionException)

Example 3 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class GenericIdpSignInHandler method startSignIn.

@Override
public void startSignIn(@NonNull FirebaseAuth auth, @NonNull HelperActivityBase activity, @NonNull String providerId) {
    setResult(Resource.forLoading());
    FlowParameters flowParameters = activity.getFlowParams();
    OAuthProvider provider = buildOAuthProvider(providerId, auth);
    if (flowParameters != null && AuthOperationManager.getInstance().canUpgradeAnonymous(auth, flowParameters)) {
        handleAnonymousUpgradeFlow(auth, activity, provider, flowParameters);
        return;
    }
    handleNormalSignInFlow(auth, activity, provider);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) OAuthProvider(com.google.firebase.auth.OAuthProvider)

Example 4 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class KickoffActivity method invalidateEmailLink.

public void invalidateEmailLink() {
    FlowParameters flowParameters = getFlowParams();
    flowParameters.emailLink = null;
    setIntent(getIntent().putExtra(ExtraConstants.FLOW_PARAMS, flowParameters));
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters)

Example 5 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class EmailLinkSignInHandlerTest method initializeHandlerWithSessionInfo.

private void initializeHandlerWithSessionInfo(@Nullable String sessionId, @Nullable String anonymousUserId, @Nullable String providerId, boolean forceSameDevice) {
    FlowParameters testParams = TestHelper.getFlowParameters(new ArrayList<String>());
    ContinueUrlBuilder continueUrlBuilder = new ContinueUrlBuilder(CONTINUE_URL);
    continueUrlBuilder.appendSessionId(sessionId);
    continueUrlBuilder.appendAnonymousUserId(anonymousUserId);
    continueUrlBuilder.appendProviderId(providerId);
    continueUrlBuilder.appendForceSameDeviceBit(forceSameDevice);
    testParams.emailLink = EMAIL_LINK + continueUrlBuilder.build();
    mHandler.initializeForTesting(testParams, mMockAuth, null);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) ContinueUrlBuilder(com.firebase.ui.auth.util.data.ContinueUrlBuilder)

Aggregations

FlowParameters (com.firebase.ui.auth.data.model.FlowParameters)27 Before (org.junit.Before)10 Application (android.app.Application)9 Test (org.junit.Test)4 AuthUI (com.firebase.ui.auth.AuthUI)3 OAuthProvider (com.google.firebase.auth.OAuthProvider)3 HashMap (java.util.HashMap)3 TextView (android.widget.TextView)2 FirebaseAuthAnonymousUpgradeException (com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException)2 FirebaseUiException (com.firebase.ui.auth.FirebaseUiException)2 IdpResponse (com.firebase.ui.auth.IdpResponse)2 UserCancellationException (com.firebase.ui.auth.data.model.UserCancellationException)2 SocialProviderResponseHandler (com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler)2 Intent (android.content.Intent)1 ImageView (android.widget.ImageView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 RestrictTo (androidx.annotation.RestrictTo)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ConstraintLayout (androidx.constraintlayout.widget.ConstraintLayout)1