@@ -114,6 +114,9 @@ public UserEntity registerNewUser(UserRegisterForm newUser) {
114
114
115
115
for (long id : userGroups ) {
116
116
try {
117
+ if (id == Groups .SYSTEM .getGroupId ())
118
+ throw new UserNotRegisteredException ("New users cannot be in group '" + Groups .SYSTEM .getDisplayName () + "'." );
119
+
117
120
groupRepository .getGroupById (id );
118
121
} catch (IllegalArgumentException exception ) {
119
122
throw new UserNotRegisteredException ("One or more groups do not exist." );
@@ -162,7 +165,7 @@ public void updateUser(long userId, UserRegisterForm userToUpdate, User authenti
162
165
if (null == userEntityToUpdate )
163
166
throw new UserNotUpdatedException ("User does not exist, use register endpoint." );
164
167
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 ()))
166
169
throw new UserNotUpdatedException ("Runtime users cannot be modified." );
167
170
168
171
Update newUpdate = new Update ();
@@ -188,8 +191,8 @@ private boolean updateGroups(Update newUpdate, long[] groupIds, boolean authenti
188
191
if (null != groupIds && groupIds .length != 0 ) {
189
192
try {
190
193
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" );
193
196
if (group == Groups .ADMIN && !authenticatedUserIsAdmin )
194
197
throw new UserNotUpdatedException ("Only admins can add users to group " + Groups .ADMIN .getDisplayName () + "." );
195
198
}
0 commit comments