Skip to content

Commit 69f7c0e

Browse files
authored
Allow setAllowNewAccounts(false) with email-link sign in (#1813)
1 parent c85355c commit 69f7c0e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
- Restore `setGithubButtonId` when using custom layouts (#1783)
33
- Improve how network errors display when they are non-fatal (#1803)
44
- Warn instead of crashing when a reserved email is used (#1644)
5+
- Allow `setAllowNewAccounts(false)` to be used with email link sign in (#1762)

auth/src/main/java/com/firebase/ui/auth/util/data/ProviderUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ public Task<List<String>> then(@NonNull Task<SignInMethodQueryResult> task) {
212212
}
213213
}
214214

215+
// In this case the developer has configured EMAIL_LINK sign in but the
216+
// user is a password user. The valid use case here is that the developer
217+
// is using admin-created accounts and combining email-link sign in with
218+
// setAllowNewAccounts(false). So we manually enable EMAIL_LINK. See:
219+
// https://github.com/firebase/FirebaseUI-Android/issues/1762#issuecomment-661115293
220+
if (allowedProviders.contains(EMAIL_LINK_PROVIDER)
221+
&& methods.contains(EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD)
222+
&& !methods.contains(EMAIL_LINK_PROVIDER)) {
223+
lastSignedInProviders.add(0, signInMethodToProviderId(EMAIL_LINK_PROVIDER));
224+
}
225+
215226
if (task.isSuccessful() && lastSignedInProviders.isEmpty()
216227
&& !methods.isEmpty()) {
217228
// There is an existing user who only has unsupported sign in methods

0 commit comments

Comments
 (0)