Skip to content
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 @@ -1124,7 +1124,6 @@ public AccountRecord getAccountByLocalAccountId(@Nullable final String environme

for (final AccountRecord accountRecord: accountRecordList) {
if (accountRecord.getLocalAccountId().equals(localAccountId)
&& accountRecord.getEnvironment().equals(environment)
&& accountHasCredential(accountRecord, appCredentials)) {
return accountRecord;
}
Expand Down Expand Up @@ -1373,9 +1372,8 @@ private CredentialType getAccessTokenCredentialTypeForAuthenticationScheme(
}

/**
* Evaluates the supplied list of Credentials. Returns true if the provided Account's
* homeAccountId matches with any of the credentials' homeAccountId.
* This does not filter on environment, as that is expected to be pre-filtered.
* Evaluates the supplied list of Credentials. Returns true if the provided Account
* 'owns' any one of these tokens.
*
* @param account The Account whose credential ownership should be evaluated.
* @param appCredentials The Credentials to evaluate.
Expand All @@ -1384,17 +1382,20 @@ private CredentialType getAccessTokenCredentialTypeForAuthenticationScheme(
private boolean accountHasCredential(@NonNull final AccountRecord account,
@NonNull final List<Credential> appCredentials) {
final String methodName = ":accountHasCredential";

final String accountHomeId = account.getHomeAccountId();
final String accountEnvironment = account.getEnvironment();

Logger.verbosePII(
TAG + methodName,
"HomeAccountId: [" + accountHomeId + "]"
+ "\n"
+ "Environment: [" + accountEnvironment + "]"
);

// Since we already filtered accounts and credentials by environment, there is no need to check
// environment again
for (final Credential credential : appCredentials) {
if (accountHomeId.equals(credential.getHomeAccountId())) {
if (accountHomeId.equals(credential.getHomeAccountId())
&& accountEnvironment.equals(credential.getEnvironment())) {
Logger.verbose(
TAG + methodName,
"Credentials located for account."
Expand Down
Loading