Sha256: 20699b2bb48b6477dbe9bd7e5e5eb8eb7555f9cffd2f73085a4bfc0d33714af4

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

class Ability
  include CanCan::Ability
  
  # commented code is left for example for hostapps. In hostapp developer can override this class for custom authorization requirements
  def initialize(user)
    
    user ||= User.new # guest user (not logged in)
    if user.super_admin?
      can :manage, :all
    elsif user.admin?
      can :manage, :all
      restricted_features_for_admin
    else
      can :manage, :all
      restricted_features_for_admin
      
      cannot :manage , User
      cannot :manage , Gluttonberg::Setting
      cannot :destroy , Gluttonberg::Asset
      
      #page roles
      #cannot :manage , Gluttonberg::Page
      cannot :change_home , Gluttonberg::Page
      cannot :destroy , Gluttonberg::Page
      cannot :publish , Gluttonberg::Page
      cannot :reorder , Gluttonberg::Page
      
      #cannot :manage , Gluttonberg::Blog
      cannot :publish , Gluttonberg::Blog
      cannot :destroy , Gluttonberg::Blog
      
      #cannot :manage , Gluttonberg::Article
      #cannot :publish , Gluttonberg::Article
      #cannot :destroy , Gluttonberg::Article
      
      #cannot :manage , Gluttonberg::Comment
      #cannot :moderate , Gluttonberg::Comment
    end
    
  end
  
  def restricted_features_for_admin
    cannot :manage , Gluttonberg::Locale
    cannot :create_or_destroy , Gluttonberg::Setting
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gluttonberg-core-2.6.4 app/models/ability.rb
gluttonberg-core-2.6.3 app/models/ability.rb
gluttonberg-core-2.6.2 app/models/ability.rb
gluttonberg-core-2.6.1 app/models/ability.rb
gluttonberg-core-2.6.0 app/models/ability.rb
gluttonberg-core-2.5.9 app/models/ability.rb
gluttonberg-core-2.5.8 app/models/ability.rb
gluttonberg-core-2.5.7 app/models/ability.rb
gluttonberg-core-2.5.6 app/models/ability.rb
gluttonberg-core-2.5.5 app/models/ability.rb
gluttonberg-core-2.5.4 app/models/ability.rb
gluttonberg-core-2.5.3 app/models/ability.rb
gluttonberg-core-2.5.2 app/models/ability.rb
gluttonberg-core-2.5.1 app/models/ability.rb
gluttonberg-core-2.5 app/models/ability.rb