I'm trying to configure a listener that changes some user details when he logs in but i got an error message saying "You do not have the permission to update users."
That is totally valid and I understand why it happens, The user that has made the login doesn't have permission to update users.
My question is if it's possible to execute the listener as a different user ?
UserService userService = ComponentAccessor.getComponent(UserService)
ApplicationUsers.from(ImmutableUser.newUser(event.getUser().getDirectoryUser()).name("New Name").toUser())
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updateUser)
if (updateUserValidationResult.isValid()) {
userService.updateUser(updateUserValidationResult)
}else{
updateUserValidationResult.getErrorCollection().each{ log.error it}
}