Sha256: 649133fd412e8d886cf6a14f2dfba91f2c57e808f0d1d46f4895e99d3728ef93

Contents?: true

Size: 577 Bytes

Versions: 34

Compression:

Stored size: 577 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Abilities
    # Defines the abilities for an admin user. Intended to be used with `cancancan`.
    class AdminAbility
      include CanCan::Ability

      attr_reader :user

      def initialize(user, context)
        @user = user
        @context = context

        define_abilities if admin?
      end

      def define_abilities
        can :read, :admin_dashboard
        can :read, Feature
        can :impersonate, :managed_users
      end

      def admin?
        @user && @user.admin?
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
decidim-core-0.10.1 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.10.0 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.9.3 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.9.2 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.9.1 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.9.0 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.8.4 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.8.3 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.8.2 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.8.1 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.8.0 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.7.4 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.7.3 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.7.2 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.7.1 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.7.0 app/models/decidim/abilities/admin_ability.rb
decidim-core-0.6.8 app/models/decidim/abilities/admin_ability.rb
decidim-0.6.8 decidim-core/app/models/decidim/abilities/admin_ability.rb
decidim-core-0.6.7 app/models/decidim/abilities/admin_ability.rb
decidim-0.6.7 decidim-core/app/models/decidim/abilities/admin_ability.rb