Allow oauth to be used for any account
This is needed to allow authentication for dasher accounts. Change-Id: Ic743cf5e027cb9dfbc85896ebae975a3ea40d7bc
This commit is contained in:
parent
e31fe0d47b
commit
bc5a832da1
|
@ -426,6 +426,13 @@ public class AccountSetupBasics extends AccountSetupActivity
|
|||
final String[] emailParts = email.split("@");
|
||||
final String domain = emailParts[1].trim();
|
||||
Provider provider = AccountSettingsUtils.findProviderForDomain(this, domain);
|
||||
if (provider == null) {
|
||||
// Maybe this is a dasher email address, just try to authenticate using google.
|
||||
// TODO STOPSHIP: at some point, the UI needs to display something like
|
||||
// "authenticate using google.com". For now, since the only oauth provider
|
||||
// we support is google, we'll just assume that is the provider.
|
||||
provider = AccountSettingsUtils.findProviderForDomain(this, "google.com");
|
||||
}
|
||||
if (provider != null && provider.oauth != null) {
|
||||
final Intent i = new Intent(this, OAuthAuthenticationActivity.class);
|
||||
i.putExtra(OAuthAuthenticationActivity.EXTRA_EMAIL_ADDRESS, email);
|
||||
|
@ -459,28 +466,15 @@ public class AccountSetupBasics extends AccountSetupActivity
|
|||
}
|
||||
|
||||
private void validateFields() {
|
||||
final boolean validEmail = !TextUtils.isEmpty(mEmailView.getText())
|
||||
&& mEmailValidator.isValid(mEmailView.getText().toString().trim());
|
||||
mOAuthButton.setEnabled(validEmail);
|
||||
|
||||
final boolean valid = !TextUtils.isEmpty(mEmailView.getText())
|
||||
&& !TextUtils.isEmpty(mPasswordView.getText())
|
||||
&& mEmailValidator.isValid(mEmailView.getText().toString().trim());
|
||||
onEnableProceedButtons(valid);
|
||||
|
||||
// TODO: This is a temporary hack to allow oauth flow to be started. It should be
|
||||
// removed when the real account setup flow is implemented.
|
||||
boolean allowOauth = false;
|
||||
if (!TextUtils.isEmpty(mEmailView.getText())
|
||||
&& mEmailValidator.isValid(mEmailView.getText().toString().trim())) {
|
||||
final String email = mEmailView.getText().toString().trim();
|
||||
final String[] emailParts = email.split("@");
|
||||
final String domain = emailParts[1].trim();
|
||||
// TODO: Note that this check reads and parses the xml file each time. This
|
||||
// should probably get cached somewhere.
|
||||
Provider provider = AccountSettingsUtils.findProviderForDomain(this, domain);
|
||||
if (provider != null && provider.oauth != null) {
|
||||
allowOauth = true;
|
||||
}
|
||||
}
|
||||
mOAuthButton.setEnabled(allowOauth);
|
||||
|
||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||
AccountSettingsUtils.checkPasswordSpaces(this, mPasswordView);
|
||||
}
|
||||
|
|
|
@ -117,6 +117,8 @@ public class OAuthAuthenticationActivity extends Activity implements
|
|||
getLoaderManager().initLoader(LOADER_ID_OAUTH_TOKEN, params,
|
||||
OAuthAuthenticationActivity.this);
|
||||
}
|
||||
// Set the result to cancelled until we have success.
|
||||
setResult(AccountSetupBasics.RESULT_OAUTH_USER_CANCELED, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue