Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 283d482

Browse files
committed
FF-255 Added remaining logic.
1 parent 1657fd5 commit 283d482

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/de/filefighter/rest/domain/user/business/UserBusinessService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public UserEntity registerNewUser(UserRegisterForm newUser) {
114114

115115
for (long id : userGroups) {
116116
try {
117+
if (id == Groups.SYSTEM.getGroupId())
118+
throw new UserNotRegisteredException("New users cannot be in group '" + Groups.SYSTEM.getDisplayName() + "'.");
119+
117120
groupRepository.getGroupById(id);
118121
} catch (IllegalArgumentException exception) {
119122
throw new UserNotRegisteredException("One or more groups do not exist.");
@@ -162,7 +165,7 @@ public void updateUser(long userId, UserRegisterForm userToUpdate, User authenti
162165
if (null == userEntityToUpdate)
163166
throw new UserNotUpdatedException("User does not exist, use register endpoint.");
164167

165-
if(Arrays.stream(userEntityToUpdate.getGroupIds()).asDoubleStream().anyMatch(id -> id == Groups.SYSTEM.getGroupId()))
168+
if (Arrays.stream(userEntityToUpdate.getGroupIds()).asDoubleStream().anyMatch(id -> id == Groups.SYSTEM.getGroupId()))
166169
throw new UserNotUpdatedException("Runtime users cannot be modified.");
167170

168171
Update newUpdate = new Update();
@@ -188,8 +191,8 @@ private boolean updateGroups(Update newUpdate, long[] groupIds, boolean authenti
188191
if (null != groupIds && groupIds.length != 0) {
189192
try {
190193
for (Groups group : groupRepository.getGroupsByIds(groupIds)) {
191-
if( group == Groups.SYSTEM)
192-
throw new UserNotUpdatedException("Users cannot be added to the '"+ Groups.SYSTEM.getDisplayName()+"' Group");
194+
if (group == Groups.SYSTEM)
195+
throw new UserNotUpdatedException("Users cannot be added to the '" + Groups.SYSTEM.getDisplayName() + "' Group");
193196
if (group == Groups.ADMIN && !authenticatedUserIsAdmin)
194197
throw new UserNotUpdatedException("Only admins can add users to group " + Groups.ADMIN.getDisplayName() + ".");
195198
}

0 commit comments

Comments
 (0)