Merge branch 'duplicate-groups' of https://github.com/ssilvert/keycloak into ssilvert-duplicate-groups
This commit is contained in:
commit
3bd3d0285d
5 files changed
+46
-2
No files matched your search
@@ -48,6 +48,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.keycloak.services.ErrorResponse;
|
||||
|
||||
/**
|
||||
* @author Bill Burke
|
||||
@@ -138,6 +139,12 @@ public class GroupResource {
|
||||
if (group == null) {
|
||||
throw new NotFoundException("Could not find group by id");
|
||||
}
|
||||
|
||||
for (GroupModel group : group.getSubGroups()) {
|
||||
if (group.getName().equals(rep.getName())) {
|
||||
return ErrorResponse.exists("Parent already contains subgroup named '" + rep.getName() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
Response.ResponseBuilder builder = Response.status(204);
|
||||
GroupModel child = null;
|
||||
|
||||
@@ -39,6 +39,7 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.keycloak.services.ErrorResponse;
|
||||
|
||||
/**
|
||||
* @author Bill Burke
|
||||
@@ -102,6 +103,12 @@ public class GroupsResource {
|
||||
public Response addTopLevelGroup(GroupRepresentation rep) {
|
||||
auth.requireManage();
|
||||
|
||||
for (GroupModel group : realm.getGroups()) {
|
||||
if (group.getName().equals(rep.getName())) {
|
||||
return ErrorResponse.exists("Top level group named '" + rep.getName() + "' already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
GroupModel child = null;
|
||||
Response.ResponseBuilder builder = Response.status(204);
|
||||
if (rep.getId() != null) {
|
||||
|
||||
Reference in new issue
Block a user