Skip to content
Snippets Groups Projects
Commit da120cd5 authored by Léo Banno-Cloutier's avatar Léo Banno-Cloutier
Browse files

/api/auth/directory/search: return empty array instead of 204

Change-Id: I18442a86f499eb8fdb36b6af9be3742defe289bc
parent f31c1bd5
No related branches found
No related tags found
No related merge requests found
......@@ -130,11 +130,6 @@ export default function EditBlueprintPermissions(props) {
)
)
.then((response) => {
if (response.status === 204) {
setUsers([]);
return;
}
const profilesResults = response.data.profiles;
const usernames = users.map((user) => user.username);
......
......@@ -73,7 +73,7 @@ export default function Users() {
const classes = useStyles();
const history = useHistory();
const [users, setUsers] = useState([]);
const [noUsersFound, setNoUsersFound] = useState(false);
const noUsersFound = users.length === 0;
const [noMatchFound, setNoMatchFound] = useState(false);
const [loading, setLoading] = useState(false);
const [progress, setProgress] = useState(0);
......@@ -104,13 +104,8 @@ export default function Users() {
)
)
.then((response) => {
if (response.status !== 204) {
setUsers(response.data.profiles);
setNumberPages(response.data.numPages);
} else {
setNoUsersFound(true);
}
setUsers(response.data.profiles);
setNumberPages(response.data.numPages);
setLoading(false);
})
.catch((error) => {
......@@ -140,16 +135,12 @@ export default function Users() {
)
.then((response) => {
setLoading(false);
if (response.status !== 204) {
setUsers(response.data.profiles);
setNumberPages(response.data.numPages);
} else {
setNoMatchFound(true);
}
setUsers(response.data.profiles);
setNumberPages(response.data.numPages);
setNoMatchFound(response.data.profiles.length === 0);
})
.catch((error) => {
setUsers([]);
setNoMatchFound(true);
setLoading(false);
if (error.response.status === 401) {
auth.authenticated = false;
......
......@@ -149,10 +149,7 @@ public class SearchDirectoryServlet extends HttpServlet {
JSONObject obj = new JSONObject();
obj.put("profiles", userProfiles);
obj.put("numPages", dataStore.NUM_PAGES);
if (!userProfiles.isEmpty()) {
resp.getOutputStream().write((obj.toString()).getBytes());
resp.setStatus(200);
} else
resp.sendError(204, "No users were found!");
resp.getOutputStream().write((obj.toString()).getBytes());
resp.setStatus(200);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment