Auth: Do not try to get token for non-existing accounts

This commit is contained in:
Marvin W 2020-12-05 10:03:22 +01:00
parent 5e39818a20
commit eaef4bc151
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
2 changed files with 11 additions and 0 deletions

View File

@ -124,6 +124,13 @@ public class AuthManager {
getAccountManager().setUserData(getAccount(), key, value);
}
public boolean accountExists() {
for (Account refAccount : getAccountManager().getAccountsByType(accountType)) {
if (refAccount.name.equalsIgnoreCase(accountName)) return true;
}
return false;
}
public String peekAuthToken() {
Log.d(TAG, "peekAuthToken: " + buildTokenKey());
return getAccountManager().peekAuthToken(getAccount(), buildTokenKey());

View File

@ -93,6 +93,10 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
Bundle result = new Bundle();
result.putString(KEY_ACCOUNT_NAME, accountName);
result.putString(KEY_ACCOUNT_TYPE, authManager.getAccountType());
if (!authManager.accountExists()) {
result.putString(KEY_ERROR, "NetworkError");
return result;
}
try {
AuthResponse res = authManager.requestAuth(false);
if (res.auth != null) {