Skip to content

Commit 7e3d057

Browse files
authored
Only request credentials for the appropriate providers (#1120)
1 parent d9200ec commit 7e3d057

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

auth/src/main/java/com/firebase/ui/auth/util/signincontainer/SignInDelegate.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,26 @@ public void onCreate(Bundle savedInstance) {
9393
}
9494

9595
FlowParameters flowParams = getFlowParams();
96-
if (flowParams.enableCredentials) {
96+
97+
// Only support password credentials if email auth is enabled
98+
boolean supportPasswords = false;
99+
for (AuthUI.IdpConfig config : flowParams.providerInfo) {
100+
if (EmailAuthProvider.PROVIDER_ID.equals(config.getProviderId())) {
101+
supportPasswords = true;
102+
}
103+
}
104+
List<String> accountTypes = getSupportedAccountTypes();
105+
106+
// If the request will be empty, avoid the step entirely
107+
boolean willRequestCredentials = supportPasswords || accountTypes.size() > 0;
108+
109+
if (flowParams.enableCredentials && willRequestCredentials) {
97110
getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_loading);
98111

99112
mCredentialsClient = GoogleApiUtils.getCredentialsClient(getActivity());
100-
101113
mCredentialsClient.request(new CredentialRequest.Builder()
102-
.setPasswordLoginSupported(true)
103-
.setAccountTypes(getSupportedAccountTypes().toArray(new String[0]))
114+
.setPasswordLoginSupported(supportPasswords)
115+
.setAccountTypes(accountTypes.toArray(new String[accountTypes.size()]))
104116
.build())
105117
.addOnCompleteListener(this);
106118
} else {

0 commit comments

Comments
 (0)