Sha256: b16c75ce996395beb7c47b871eff779a0afc8078d23d5a6929366a162c1d121b
Contents?: true
Size: 781 Bytes
Versions: 41
Compression:
Stored size: 781 Bytes
Contents
# frozen_string_literal: true module Decidim module Abilities # Defines the abilities for an user with role 'user_manager'. # Intended to be used with `cancancan`. class UserManagerAbility include CanCan::Ability attr_reader :user def initialize(user, context) @user = user @context = context define_abilities if not_admin? && user_manager? end def define_abilities can :read, :admin_dashboard can :impersonate, :managed_users end # Whether the user is an admin or not. def not_admin? @user && !@user.admin? end # Whether the user has the user_manager role or not. def user_manager? @user.role? "user_manager" end end end end
Version data entries
41 entries across 41 versions & 2 rubygems