Search in sources :

Example 6 with ActionCodeSettings

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

the class AuthUITest method testSignInIntentBuilder_anonymousUpgradeWithEmailLinkCrossDevice_expectThrows.

@Test(expected = IllegalStateException.class)
public void testSignInIntentBuilder_anonymousUpgradeWithEmailLinkCrossDevice_expectThrows() {
    ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder().setUrl(URL).build();
    IdpConfig config = new IdpConfig.EmailBuilder().enableEmailLinkSignIn().setActionCodeSettings(actionCodeSettings).build();
    AuthUI.getInstance().createSignInIntentBuilder().setAvailableProviders(Arrays.asList(config)).enableAnonymousUsersAutoUpgrade();
}
Also used : IdpConfig(com.firebase.ui.auth.AuthUI.IdpConfig) ActionCodeSettings(com.google.firebase.auth.ActionCodeSettings) Test(org.junit.Test)

Example 7 with ActionCodeSettings

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

the class AuthUITest method testEmailBuilder_withSetDefaultEmail_expectSuccess.

@Test
public void testEmailBuilder_withSetDefaultEmail_expectSuccess() {
    ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder().setUrl(URL).build();
    IdpConfig config = new IdpConfig.EmailBuilder().setDefaultEmail(TestConstants.EMAIL).setActionCodeSettings(actionCodeSettings).build();
    assertThat(config.getParams().getString(ExtraConstants.DEFAULT_EMAIL)).isEqualTo(TestConstants.EMAIL);
}
Also used : IdpConfig(com.firebase.ui.auth.AuthUI.IdpConfig) ActionCodeSettings(com.google.firebase.auth.ActionCodeSettings) Test(org.junit.Test)

Example 8 with ActionCodeSettings

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

the class AuthUITest method testEmailBuilder_withActionCodeSettingsAndHandleCodeInAppFalse_expectThrows.

@Test(expected = IllegalStateException.class)
public void testEmailBuilder_withActionCodeSettingsAndHandleCodeInAppFalse_expectThrows() {
    ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder().setUrl(URL).build();
    new IdpConfig.EmailBuilder().enableEmailLinkSignIn().setActionCodeSettings(actionCodeSettings).build();
}
Also used : IdpConfig(com.firebase.ui.auth.AuthUI.IdpConfig) ActionCodeSettings(com.google.firebase.auth.ActionCodeSettings) Test(org.junit.Test)

Example 9 with ActionCodeSettings

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

the class EmailLinkSendEmailHandler method sendSignInLinkToEmail.

public void sendSignInLinkToEmail(@NonNull final String email, @NonNull final ActionCodeSettings actionCodeSettings, @Nullable final IdpResponse idpResponseForLinking, final boolean forceSameDevice) {
    if (getAuth() == null) {
        return;
    }
    setResult(Resource.forLoading());
    final String anonymousUserId = AuthOperationManager.getInstance().canUpgradeAnonymous(getAuth(), getArguments()) ? getAuth().getCurrentUser().getUid() : null;
    final String sessionId = SessionUtils.generateRandomAlphaNumericString(SESSION_ID_LENGTH);
    ActionCodeSettings mutatedSettings = addSessionInfoToActionCodeSettings(actionCodeSettings, sessionId, anonymousUserId, idpResponseForLinking, forceSameDevice);
    getAuth().sendSignInLinkToEmail(email, mutatedSettings).addOnCompleteListener(task -> {
        if (task.isSuccessful()) {
            EmailLinkPersistenceManager.getInstance().saveEmail(getApplication(), email, sessionId, anonymousUserId);
            setResult(Resource.forSuccess(email));
        } else {
            setResult(Resource.forFailure(task.getException()));
        }
    });
}
Also used : ActionCodeSettings(com.google.firebase.auth.ActionCodeSettings)

Example 10 with ActionCodeSettings

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

the class EmailActivity method showRegisterEmailLinkFragment.

private void showRegisterEmailLinkFragment(AuthUI.IdpConfig emailConfig, String email) {
    ActionCodeSettings actionCodeSettings = emailConfig.getParams().getParcelable(ExtraConstants.ACTION_CODE_SETTINGS);
    EmailLinkFragment fragment = EmailLinkFragment.newInstance(email, actionCodeSettings);
    switchFragment(fragment, R.id.fragment_register_email, EmailLinkFragment.TAG);
}
Also used : ActionCodeSettings(com.google.firebase.auth.ActionCodeSettings)

Aggregations

ActionCodeSettings (com.google.firebase.auth.ActionCodeSettings)15 Test (org.junit.Test)8 IdpConfig (com.firebase.ui.auth.AuthUI.IdpConfig)6 IdpResponse (com.firebase.ui.auth.IdpResponse)3 Resource (com.firebase.ui.auth.data.model.Resource)3 InOrder (org.mockito.InOrder)3 AuthUI (com.firebase.ui.auth.AuthUI)2 ArrayList (java.util.ArrayList)2 NonNull (androidx.annotation.NonNull)1 FirebaseAuthActionCodeException (com.google.firebase.auth.FirebaseAuthActionCodeException)1 FirebaseAuthInvalidCredentialsException (com.google.firebase.auth.FirebaseAuthInvalidCredentialsException)1