summaryrefslogtreecommitdiff
path: root/app/policies
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2016-08-16 16:29:19 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2016-08-30 11:39:22 -0700
commit9a0ea1350131368b9b723f1a9581bbfffe7c43f8 (patch)
treeeb85189813369c421e992661029c3d4b22685b1a /app/policies
parent2944022835d872b472d8691082ef67aa3057d2b4 (diff)
downloadgitlab-ce-9a0ea1350131368b9b723f1a9581bbfffe7c43f8.tar.gz
factor in global permissions
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/base_policy.rb4
-rw-r--r--app/policies/global_policy.rb7
2 files changed, 9 insertions, 2 deletions
diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb
index 12f60d8f76e..5a5b99c81c8 100644
--- a/app/policies/base_policy.rb
+++ b/app/policies/base_policy.rb
@@ -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
diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb
new file mode 100644
index 00000000000..94a2906444a
--- /dev/null
+++ b/app/policies/global_policy.rb
@@ -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