Skip to content

Added setDefaultEmail for EmailBuilder #1866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,17 @@ public EmailBuilder setForceSameDevice() {
return this;
}

/**
* Sets a default sign in email, if the given email has been registered before, then
* it will ask the user for password, if the given email it's not registered, then
* it starts signing up the default email.
*/
@NonNull
public EmailBuilder setDefaultEmail(String email) {
getParams().putString(ExtraConstants.DEFAULT_EMAIL, email);
return this;
}

@Override
public IdpConfig build() {
if (super.mProviderId.equals(EMAIL_LINK_PROVIDER)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
responseForLinking, forceSameDevice);
switchFragment(fragment, R.id.fragment_register_email, EmailLinkFragment.TAG);
} else {
AuthUI.IdpConfig emailConfig = ProviderUtils.getConfigFromIdps(
getFlowParams().providers, EmailAuthProvider.PROVIDER_ID);

if (emailConfig != null) {
email = emailConfig.getParams().getString(ExtraConstants.DEFAULT_EMAIL);;
}
// Start with check email
CheckEmailFragment fragment = CheckEmailFragment.newInstance(email);
switchFragment(fragment, R.id.fragment_register_email, CheckEmailFragment.TAG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public final class ExtraConstants {
public static final String CREDENTIAL = "extra_credential";

public static final String EMAIL = "extra_email";
public static final String DEFAULT_EMAIL = "extra_default_email";
public static final String ALLOW_NEW_EMAILS = "extra_allow_new_emails";
public static final String REQUIRE_NAME = "extra_require_name";
public static final String GOOGLE_SIGN_IN_OPTIONS = "extra_google_sign_in_options";
Expand Down