Sha256: 3567be3fe34d67271d85588b8483d5fb0276c5b84b24715548f72dcf3e3da71c

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 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, ParticipatoryProcess
        can :read, Feature
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-core-0.4.4 app/models/decidim/abilities/admin_ability.rb