Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Fix JMH-66: Improve username resolution #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -111,8 +111,17 @@ else if (responseStatus < 200 || responseStatus >= 300 || content == null)
Map<String, Object> getUserIfOneIsFound(String username, Object content) {
if (username.contains("@")) {
List<Map<String, Object>> foundUsers = ((List<Map<String, Object>>) content);
if (foundUsers.isEmpty()) return null;
return foundUsers.get(0);
// If only one user is found, don't try to match the email to allow users
// using their alternative email addresses
if (foundUsers.size() == 1) {
return foundUsers.get(0);
}

for (Map<String, Object> cUser: foundUsers) {
if (((String)cUser.get("emailAddress")).equals(username))
return cUser;
}
return null;
} else {
return (Map<String, Object>)content;
}
Expand All @@ -121,7 +130,7 @@ Map<String, Object> getUserIfOneIsFound(String username, Object content) {
String getUserSearchUrl(String username) {
if (username.contains("@"))
return String.format(
"%s/rest/api/latest/user/search?maxResults=1&username=%s",
"%s/rest/api/latest/user/search?maxResults=-1&username=%s",
configuration.getJiraBaseUrl(), username);
else
return String.format(
Expand Down