forked from External/greenlight
GRN2-176: Create a role editor that allows admins to specify what permissions each role has (#709)
* Add roles editor * Add colour selection ability to roles * Add ability to assign roles to users in the UI * Remove rolify and replace it with our own custom roles implemenation * - Fix all existing roles functionality - Fix super admins * Fix bugs with new customers not have default roles * Add can't create room setting * Code improvements * Fix migration * Add tests for new methods * Translate reserved role names * Pull roles from saml/ldap * Fix rspec * Fix scrutinizer issues * Fix email promoted/demoted tests * Apply comments * Redirect directly to the main room * Add comments
This commit is contained in:
committed by
Jesus Federico
parent
02b342b157
commit
4fc1714db8
@ -20,4 +20,20 @@ module UsersHelper
|
||||
def recaptcha_enabled?
|
||||
Rails.configuration.recaptcha_enabled
|
||||
end
|
||||
|
||||
def disabled_roles(user)
|
||||
current_user_role = current_user.highest_priority_role
|
||||
|
||||
# Admins are able to remove the admin role from other admins
|
||||
# For all other roles they can only add/remove roles with a higher priority
|
||||
disallowed_roles = if current_user_role.name == "admin"
|
||||
Role.editable_roles(@user_domain).where("priority < #{current_user_role.priority}")
|
||||
.pluck(:id)
|
||||
else
|
||||
Role.editable_roles(@user_domain).where("priority <= #{current_user_role.priority}")
|
||||
.pluck(:id)
|
||||
end
|
||||
|
||||
user.roles.by_priority.pluck(:id) | disallowed_roles
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user