Skip to content

Allow setAllowNewAccounts(false) with email-link sign in #1813

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 2 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- Restore `setGithubButtonId` when using custom layouts (#1783)
- Improve how network errors display when they are non-fatal (#1803)
- Warn instead of crashing when a reserved email is used (#1644)
- Allow `setAllowNewAccounts(false)` to be used with email link sign in (#1762)
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ public Task<List<String>> then(@NonNull Task<SignInMethodQueryResult> task) {
}
}

// In this case the developer has configured EMAIL_LINK sign in but the
// user is a password user. The valid use case here is that the developer
// is using admin-created accounts and combining email-link sign in with
// setAllowNewAccounts(false). So we manually enable EMAIL_LINK. See:
// https://github.com/firebase/FirebaseUI-Android/issues/1762#issuecomment-661115293
if (allowedProviders.contains(EMAIL_LINK_PROVIDER)
&& methods.contains(EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD)
&& !methods.contains(EMAIL_LINK_PROVIDER)) {
lastSignedInProviders.add(0, signInMethodToProviderId(EMAIL_LINK_PROVIDER));
}

if (task.isSuccessful() && lastSignedInProviders.isEmpty()
&& !methods.isEmpty()) {
// There is an existing user who only has unsupported sign in methods
Expand Down