# "Update" Roles with User Management Component

**URL:** <https://forum.inductiveautomation.com/t/update-roles-with-user-management-component/10926>\
**Category:** Ignition\
**Created:** [December 16, 2015, 2:28pm UTC](https://forum.inductiveautomation.com/t/update-roles-with-user-management-component/10926 "2015-12-16T14:28:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [December 16, 2015, 2:28pm UTC](https://forum.inductiveautomation.com/t/update-roles-with-user-management-component/10926/1 "2015-12-16T14:28:05Z")

</div>

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]
```

---

<div class="post-metadata">

**Author:** ![Weffrey](https://avatars.discourse-cdn.com/v4/letter/w/6a8cbe/32.png) [@Weffrey](https://forum.inductiveautomation.com/u/Weffrey)\
**Post date:** [December 26, 2015, 7:19am UTC](https://forum.inductiveautomation.com/t/update-roles-with-user-management-component/10926/2 "2015-12-26T07:19:06Z")

</div>

I am having the same problem on version 7.8.0. I’d love to find out if there is a solution in the works. It seems like the user object might not allow one to edit it prior to saving, and I cannot find another way in the system scripting functions to change roles.
