2016-08-16 14:10:34 -04:00
|
|
|
class IssuePolicy < IssuablePolicy
|
2016-11-01 16:18:51 -04:00
|
|
|
# This class duplicates the same check of Issue#readable_by? for performance reasons
|
|
|
|
# Make sure to sync this class checks with issue.rb to avoid security problems.
|
|
|
|
# Check commit 002ad215818450d2cbbc5fa065850a953dc7ada8 for more information.
|
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "User can read confidential issues"
|
|
|
|
condition(:can_read_confidential) do
|
|
|
|
@user && IssueCollection.new([@subject]).visible_to(@user).any?
|
2016-08-16 14:10:34 -04:00
|
|
|
end
|
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "Issue is confidential"
|
|
|
|
condition(:confidential, scope: :subject) { @subject.confidential? }
|
2016-08-16 14:10:34 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { confidential & ~can_read_confidential }.policy do
|
|
|
|
prevent :read_issue
|
2017-12-11 09:21:06 -05:00
|
|
|
prevent :read_issue_iid
|
2017-04-06 17:06:42 -04:00
|
|
|
prevent :update_issue
|
|
|
|
prevent :admin_issue
|
2016-08-16 14:10:34 -04:00
|
|
|
end
|
|
|
|
end
|