removed invalid search (#16913)

fixes: https://github.com/keycloak/keycloak-ui/issues/4320
This commit is contained in:
Erik Jan de Wit 2023-02-20 08:59:26 +01:00 committed by GitHub
parent 055b7c3b16
commit d0828148a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,15 +57,12 @@ public class GroupsResource {
@QueryParam("exact") @DefaultValue("false") boolean exact) { @QueryParam("exact") @DefaultValue("false") boolean exact) {
this.auth.groups().requireList(); this.auth.groups().requireList();
final Stream<GroupModel> stream; final Stream<GroupModel> stream;
if (!"".equals(search)) {
if (global) { if (global) {
stream = session.groups().searchForGroupByNameStream(realm, search, exact, first, max); stream = session.groups().searchForGroupByNameStream(realm, search.trim(), exact, first, max);
} else { } else {
stream = this.realm.getTopLevelGroupsStream().filter(g -> g.getName().contains(search)).skip(first).limit(max); stream = this.realm.getTopLevelGroupsStream().filter(g -> g.getName().contains(search)).skip(first).limit(max);
} }
} else {
stream = this.realm.getTopLevelGroupsStream(first, max);
}
return stream.map(g -> toGroupHierarchy(g, search, exact)); return stream.map(g -> toGroupHierarchy(g, search, exact));
} }