diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 00:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 00:09:16 +0300 |
commit | 154b9bae142ba15fec753f44327654595094b879 (patch) | |
tree | 027f8ae024961778d5b00c77a72fe302f985d4f3 /app/policies | |
parent | 2c156e3c7bbade01c36eee18327f1ced6eebea79 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/note_policy.rb | 7 | ||||
-rw-r--r-- | app/policies/snippet_policy.rb | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/policies/note_policy.rb b/app/policies/note_policy.rb index 32be89439ba..82ebf6ba6a5 100644 --- a/app/policies/note_policy.rb +++ b/app/policies/note_policy.rb @@ -12,6 +12,7 @@ class NotePolicy < BasePolicy condition(:editable, scope: :subject) { @subject.editable? } condition(:can_read_noteable) { can?(:"read_#{@subject.noteable_ability_name}") } + condition(:commit_is_deleted) { @subject.for_commit? && @subject.noteable.blank? } condition(:is_visible) { @subject.system_note_with_references_visible_for?(@user) } @@ -25,12 +26,16 @@ class NotePolicy < BasePolicy # If user can't read the issue/MR/etc then they should not be allowed to do anything to their own notes rule { ~can_read_noteable }.policy do - prevent :read_note prevent :admin_note prevent :resolve_note prevent :award_emoji end + # Special rule for deleted commits + rule { ~(can_read_noteable | commit_is_deleted) }.policy do + prevent :read_note + end + rule { is_author }.policy do enable :read_note enable :admin_note diff --git a/app/policies/snippet_policy.rb b/app/policies/snippet_policy.rb new file mode 100644 index 00000000000..64c56e8091d --- /dev/null +++ b/app/policies/snippet_policy.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class SnippetPolicy < PersonalSnippetPolicy +end |