Admin Assigning Users to a Role - hmislk/hmis GitHub Wiki
Assigning Users to a Role
Overview
Roles are assigned to users either at the time of user creation or afterwards through the role management screen. A user can hold one primary role. This page covers the role assignment workflow from the role side — finding which users belong to a role and adding role privileges to a user's department.
When to Use
- Adding role-based privileges to a user for a specific department
- Reviewing which users have been assigned a given role
- Resetting a user's role privileges to match the current role definition after the role was updated
Navigating to Role-User Management
- Click Administration → Manage Users
- Navigate to the role management area
- Select the role from the list
- Click Manage User Role Users from the role actions
Required privilege: AdminManagingUsers
Assigning a Role to a User from the User Record
The most common way to assign a role is during user creation or editing:
- Open Administration → Manage Users
- Click Manage User for the user you want to change
- The role assignment is made during user creation (the User Role field on the Add New User form)
For existing users, the role can be updated via the user edit form.
Applying Role Privileges to a Department
The Manage User Role Users screen allows you to push role privileges to a specific user-department combination:
- The User field shows the selected user (currently read-only in view)
- Select the Department from the dropdown
- Select the Role from the dropdown
- Click Add Role Privileges to Department
This operation copies the role's current privilege set to the user's individual privilege record for that department. It is useful when you want a user to have role-equivalent access in a department that they are not formally assigned to.
Resetting Privileges
In the role-user table, each row has a Reset Privilege button (shown when needUpdateUserRole is true). Clicking this re-syncs the user's privileges with the current role definition. Use this after updating the role's privileges so existing users reflect the new set.
Removing a Role Assignment
Click the trash icon in the Actions column to remove a user's role assignment. This does not delete the user; it only removes their role-based privileges.
Technical Notes (Admin/Developer)
Role assignment is handled by WebUserRoleUserController. The addUsersToDepartmentRoleWithPrivileges() method creates a WebUserRoleUser entity linking the user, department, and role, then copies the role's WebUserRolePrivilege entries to UserPrivilege records for that user-department pair. The resetRolePrivileges(user) method re-applies the current role privileges to override any individual changes.