2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
class IssuePolicy < IssuablePolicy
|
2016-11-24 13:41:30 +05:30
|
|
|
# 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.
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
include CrudPolicyHelpers
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
desc "User can read confidential issues"
|
|
|
|
condition(:can_read_confidential) do
|
|
|
|
@user && IssueCollection.new([@subject]).visible_to(@user).any?
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
desc "Issue is confidential"
|
|
|
|
condition(:confidential, scope: :subject) { @subject.confidential? }
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
rule { confidential & ~can_read_confidential }.policy do
|
2019-09-04 21:01:54 +05:30
|
|
|
prevent(*create_read_update_admin_destroy(:issue))
|
2018-03-27 19:54:05 +05:30
|
|
|
prevent :read_issue_iid
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
rule { ~can?(:read_issue) }.prevent :create_note
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
rule { locked }.policy do
|
|
|
|
prevent :reopen_issue
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
IssuePolicy.prepend_if_ee('::EE::IssuePolicy')
|