factor in global permissions
This commit is contained in:
parent
2944022835
commit
9a0ea13501
2 changed files with 9 additions and 2 deletions
|
@ -4,6 +4,8 @@ class BasePolicy
|
|||
end
|
||||
|
||||
def self.class_for(subject)
|
||||
return GlobalPolicy if subject.nil?
|
||||
|
||||
subject.class.ancestors.each do |klass|
|
||||
next unless klass.name
|
||||
|
||||
|
@ -59,8 +61,6 @@ class BasePolicy
|
|||
private
|
||||
|
||||
def collect_rules(&b)
|
||||
return Set.new if @subject.nil?
|
||||
|
||||
@can = Set.new
|
||||
@cannot = Set.new
|
||||
yield
|
||||
|
|
7
app/policies/global_policy.rb
Normal file
7
app/policies/global_policy.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class GlobalPolicy < BasePolicy
|
||||
def rules
|
||||
return unless @user
|
||||
can! :create_group if @user.can_create_group
|
||||
can! :read_users_list
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue