Sha256: 127dcf41ce80d5cb90e3b4545c7f9f00e564831bae43fc1741d9cc65c20c8211

Contents?: true

Size: 1.11 KB

Versions: 21

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require "cancancan"

class Ability
  include CanCan::Ability

  def initialize(user)
    return unless user

    case user.profile
    when "admin"
      add_admin_abilities
      add_publisher_abilities
      add_contributor_abilities
    when "publisher"
      add_publisher_abilities
      add_contributor_abilities
    when "contributor"
      add_contributor_abilities
    end
  end

  private

  def add_admin_abilities
    can :manage, "admin/migrations"
    can :manage, "admin/seo"
    can :manage, "admin/settings"
    can :manage, "admin/sidebar"
    can :manage, "admin/textfilters"
    can :manage, "admin/themes"
    can :manage, "admin/users"
  end

  def add_publisher_abilities
    can :manage, "admin/content"
    can :manage, "admin/feedback"
    can :manage, "admin/notes"
    can :manage, "admin/pages"
    can :manage, "admin/post_types"
    can :manage, "admin/redirects"
    can :manage, "admin/resources"
    can :manage, "admin/tags"

    can :manage, "articles"
  end

  def add_contributor_abilities
    can :manage, "admin/dashboard"
    can :manage, "admin/profiles"
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 app/models/ability.rb
HornsAndHooves-publify_core-10.4.0 app/models/ability.rb
HornsAndHooves-publify_core-10.3.0 app/models/ability.rb
HornsAndHooves-publify_core-10.2.0 app/models/ability.rb
publify_core-9.2.10 app/models/ability.rb
HornsAndHooves-publify_core-10.1.1 app/models/ability.rb
HornsAndHooves-publify_core-10.1.0 app/models/ability.rb
HornsAndHooves-publify_core-10.0.3 app/models/ability.rb
HornsAndHooves-publify_core-10.0.2 app/models/ability.rb
HornsAndHooves-publify_core-10.0.1 app/models/ability.rb
HornsAndHooves-publify_core-10.0.0 app/models/ability.rb
publify_core-9.2.9 app/models/ability.rb
publify_core-9.2.8 app/models/ability.rb
publify_core-9.2.7 app/models/ability.rb
publify_core-9.2.6 app/models/ability.rb
publify_core-9.2.5 app/models/ability.rb
publify_core-9.2.4 app/models/ability.rb
publify_core-9.2.3 app/models/ability.rb
publify_core-9.2.2 app/models/ability.rb
publify_core-9.2.1 app/models/ability.rb