Remove custom admin roles assignments if user is an admin
What does this MR do and why?
Update Users::MemberRoles::AssignService to remove a user's user_member_roles records if they are admin. Admins already have all the ability custom admin roles can grant so existing assignments are unnecessary.
References
Implements Update Users::MemberRoles::AssignService to rem... (#535965 - closed). Part of Add ability to assign custom role in user settings (#501553 - closed).
Screenshots or screen recordings
Screen_Recording_2025-04-15_at_4.34.05_PM
How to set up and validate locally
-
Enable admin custom roles feature flag
$ rails c > Feature.enable(:custom_admin_roles) -
Login with an admin user (e.g.
root) -
Create a custom admin role
Create custom admin role
Screen_Recording_2025-04-07_at_3.56.16_PM -
Go to
/admin/userspage and create a new user (type: Auditor) with one of the custom admin role you created -
On the new user show page click on
Editand verify that the custom admin role you selected during creation is correctly displayed -
Change the user's type to Admin and click
Save changes -
Click on
Editagain and verify that the custom admin role has been removed
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.