diff --git a/src/main/java/com/knecon/fforesight/tenantusermanagement/controller/external/UserPreferenceController.java b/src/main/java/com/knecon/fforesight/tenantusermanagement/controller/external/UserPreferenceController.java index 0b0dabb..2ba08db 100644 --- a/src/main/java/com/knecon/fforesight/tenantusermanagement/controller/external/UserPreferenceController.java +++ b/src/main/java/com/knecon/fforesight/tenantusermanagement/controller/external/UserPreferenceController.java @@ -45,23 +45,19 @@ public class UserPreferenceController implements UserPreferenceResource, PublicR @PreAuthorize("hasAuthority('" + UserManagementPermissions.MANAGE_USER_PREFERENCES + "')") public void setAttribute(@PathVariable(KEY_PARAMETER_NAME) String key, List values) { - try { - String userId = KeycloakSecurity.getUserId(); + String userId = KeycloakSecurity.getUserId(); - var userResource = userService.getUserResource(userId); - var userRepresentation = userResource.toRepresentation(); + var userResource = userService.getUserResource(userId); + var userRepresentation = userResource.toRepresentation(); - var attributes = userRepresentation.getAttributes(); - if (attributes == null) { - attributes = new HashMap<>(); - } - attributes.put(key, values); - userRepresentation.setAttributes(attributes); - - userResource.update(userRepresentation); - } catch(NotFoundException exception) { - throw new ForbiddenException("user could not be authenticated because user data does not exist"); + var attributes = userRepresentation.getAttributes(); + if (attributes == null) { + attributes = new HashMap<>(); } + attributes.put(key, values); + userRepresentation.setAttributes(attributes); + + userResource.update(userRepresentation); }