Open kainio opened 1 month ago
I think the way it is implemented doesn't take into account to remove unselected roles:
/**
* Updates the user.
*
* @param id the id of the user
* @param userParameter the user parameter
* @return the response entity
* @throws URISyntaxException the URI syntax exception
*/
@PutMapping("{id}")
public ResponseEntity<URI> updateUser(@PathVariable("id") String id, @Valid @RequestBody UserParameter userParameter)
throws URISyntaxException {
User user = userService.updateUser(id, userParameter.getUsername(), userParameter.getPassword(), userParameter.getTenant());
userService.assignUserRolesByIds(user, userParameter.getRoles());
return ResponseEntity.created(new URI(BaseEndpoint.PREFIX_ENDPOINT_SECURITY + "users/" + user.getId()))
.build();
}
public void assignUserRolesByIds(User user, Long[] roleIds) {
for (Long roleId : roleIds) {
Role role = roleService.findById(roleId);
UserRoleAssignment assignment = new UserRoleAssignment();
assignment.setUser(user);
assignment.setRole(role);
if (!assignmentRepository.findByUserAndRole(user, role)
.isPresent()) {
assignmentRepository.save(assignment);
}
}
}
Describe the bug In the user dialog, when trying to delete a role or more from a user, the change didn't apply.
To Reproduce Steps to reproduce the behavior:
Expected behavior The unselected roles should be removed from the user's roles
Desktop:
Additional context Using dirigible 10.6.13