I want to add the user management component to one of my projects, but only allow users to edit roles for that specific project. I am able to filter the roles fine, BUT if the component edits a user with additional permissions that are filtered out, they are removed as well, basically striping the user of their permissions for other projects.
I want to use the onSaveUser method to “merge” the current roles with the newly requested roles, but I cannot seem to figure out the correct scripting to update the roles in the user before the save is completed.
Here is what I have so far… any ideas?
[code] # Get the current list of roles assigned to the user
currentRoles = system.user.getUser(’’, user.get(‘username’)).getRoles()
requestedRoles = user.getRoles()
# Remove any of the roles we care about updating from the current role list if 'Magnet Strength User' not in requestedRoles: currentRoles.remove('Magnet Strength User') if 'Magnet Strength Admin' not in requestedRoles: currentRoles.remove('Magnet Strength Admin') # Extend the role list and update the user to be saved if len(requestedRoles) > 0: currentRoles.extend(requestedRoles) user.roles = currentRoles[/code]