Skip to content

Commit

Permalink
Authenticate user with username instead of userid when UserStorePrefe…
Browse files Browse the repository at this point in the history
…renceOrderConfigured.
  • Loading branch information
mpmadhavig committed Oct 12, 2023
1 parent e806474 commit 1aa671f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void resolveDistinctUsersForClaims(String loginAttribute, List<String> a
if (distinctUsers.size() == 1) {
Map.Entry<String, List<User>> entry = distinctUsers.entrySet().iterator().next();
setResolvedUserResult(entry.getValue(), entry.getKey(), loginAttribute, resolvedUserResult,
claimManager.getClaim(entry.getKey()));
claimManager.getClaim(entry.getKey()), !userStorePreferenceOrder.isEmpty());
} else {
resolvedUserResult.setErrorMessage("Found multiple users for " + allowedAttributes +
" to value " + loginAttribute);
Expand Down Expand Up @@ -283,14 +283,19 @@ private IterativeUserStoreManager generateUserStoreChain(List<String> userStoreP
}

private void setResolvedUserResult(List<User> userList, String claimURI,
String loginAttribute, ResolvedUserResult resolvedUserResult, Claim claim)
String loginAttribute, ResolvedUserResult resolvedUserResult, Claim claim,
boolean IsUserStorePreferenceOrderConfigured)
throws org.wso2.carbon.user.core.UserStoreException {

if (userList.size() == 1) {
resolvedUserResult.setResolvedStatus(ResolvedUserResult.UserResolvedStatus.SUCCESS);
resolvedUserResult.setResolvedClaim(claimURI);
resolvedUserResult.setResolvedValue(loginAttribute);
User user = userList.get(0);
// To authenticate user with the username and password flow.
if (IsUserStorePreferenceOrderConfigured) {
user.setUserID(null);
}
user.setUsername(user.getDomainQualifiedUsername());
resolvedUserResult.setUser(user);
} else if (userList.size() > 1) {
Expand Down

0 comments on commit 1aa671f

Please sign in to comment.