Skip to content

Commit

Permalink
filter by an email
Browse files Browse the repository at this point in the history
  • Loading branch information
Slawomir Wieczorek committed Dec 3, 2024
1 parent f3c3192 commit 9a40951
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,16 @@ public void validateUserHasAccessToContext(String contextKey, String reason) {

public List<AdUserDto> searchUser(String email) {
if (email == null || email.length() < 3) {
return new ArrayList<>();
return Collections.emptyList();
}
return new ArrayList<>(new LinkedHashSet<>(userLookupProviderManager.searchUserByEmail(email)));

List<AdUserDto> users = userLookupProviderManager.searchUserByEmail(email);
Set<String> uniqueEmails = new HashSet<>();

return users.stream()
.filter(Objects::nonNull)
.filter(user -> uniqueEmails.add(user.getEmail()))
.collect(Collectors.toList());
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 9a40951

Please sign in to comment.