Merge branch 'RED-8343-fix' into 'main'
RED-8343: change 500 to 403 See merge request fforesight/tenant-user-management-service!78
This commit is contained in:
commit
7f220bd348
@ -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<String> 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user