summaryrefslogtreecommitdiff
path: root/app/policies/issue_policy.rb
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2016-08-16 11:10:34 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2016-08-30 11:39:22 -0700
commit4d904bf3521b4600db228c48214f3892e86ac72a (patch)
tree098b9c292e5b8ff1b1296a4a5aed20127124ec8f /app/policies/issue_policy.rb
parent1ca9b3354a350b83d1e025b3d46280bc5bb60f2b (diff)
downloadgitlab-ce-4d904bf3521b4600db228c48214f3892e86ac72a.tar.gz
port issues to Issu{able,e}Policy
Diffstat (limited to 'app/policies/issue_policy.rb')
-rw-r--r--app/policies/issue_policy.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/policies/issue_policy.rb b/app/policies/issue_policy.rb
new file mode 100644
index 00000000000..08538861364
--- /dev/null
+++ b/app/policies/issue_policy.rb
@@ -0,0 +1,27 @@
+class IssuePolicy < IssuablePolicy
+ def issue
+ @subject
+ end
+
+ def rules
+ super
+
+ if @subject.confidential? && !can_read_confidential?
+ cannot! :read_issue
+ cannot! :admin_issue
+ cannot! :update_issue
+ cannot! :read_issue
+ end
+ end
+
+ private
+
+ def can_read_confidential?
+ return false unless @user
+ return true if @user.admin?
+ return true if @subject.author == @user
+ return true if @subject.assignee == @user
+ return true if @subject.project.team.member?(@user, Gitlab::Access::REPORTER)
+ false
+ end
+end