Skip to content

Only request credentials for the appropriate providers #1120

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 1 commit into from
Jan 23, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,26 @@ public void onCreate(Bundle savedInstance) {
}

FlowParameters flowParams = getFlowParams();
if (flowParams.enableCredentials) {

// Only support password credentials if email auth is enabled
boolean supportPasswords = false;
for (AuthUI.IdpConfig config : flowParams.providerInfo) {
if (EmailAuthProvider.PROVIDER_ID.equals(config.getProviderId())) {
supportPasswords = true;
}
}
List<String> accountTypes = getSupportedAccountTypes();

// If the request will be empty, avoid the step entirely
boolean willRequestCredentials = supportPasswords || accountTypes.size() > 0;

if (flowParams.enableCredentials && willRequestCredentials) {
getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_loading);

mCredentialsClient = GoogleApiUtils.getCredentialsClient(getActivity());

mCredentialsClient.request(new CredentialRequest.Builder()
.setPasswordLoginSupported(true)
.setAccountTypes(getSupportedAccountTypes().toArray(new String[0]))
.setPasswordLoginSupported(supportPasswords)
.setAccountTypes(accountTypes.toArray(new String[accountTypes.size()]))
.build())
.addOnCompleteListener(this);
} else {
Expand Down