Sha256: e0f3255f35566d9b03817a172609806d5f3c739a1ee1a06a49050f358f670204
Contents?: true
Size: 989 Bytes
Versions: 18
Compression:
Stored size: 989 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin module Abilities # Defines the abilities for a user with role 'user_manager' in the admin section. # Intended to be used with `cancancan`. class UserManagerAbility < Decidim::Abilities::UserManagerAbility def define_abilities super can :manage, :managed_users cannot [:new, :create], :managed_users if empty_available_authorizations? can :impersonate, Decidim::User do |user_to_impersonate| user_to_impersonate.managed? && Decidim::ImpersonationLog.active.where(admin: user).empty? end can :promote, Decidim::User do |user_to_promote| user_to_promote.managed? && Decidim::ImpersonationLog.active.where(admin: user).empty? end end private def empty_available_authorizations? user.organization.available_authorizations.empty? end end end end end
Version data entries
18 entries across 18 versions & 2 rubygems