gitlab-org--gitlab-foss/app/policies/personal_snippet_policy.rb
Sean McGivern c1892f6c90 Remove the comment_personal_snippet permission
This is now entirely handled by `create_note`:

1. Project snippets prevent `create_note`.
2. Uploads already only support routing for personal snippets.

This simplifies some policies and access checks, too!
2019-05-02 11:13:42 +01:00

34 lines
970 B
Ruby

# frozen_string_literal: true
class PersonalSnippetPolicy < BasePolicy
condition(:public_snippet, scope: :subject) { @subject.public? }
condition(:is_author) { @user && @subject.author == @user }
condition(:internal_snippet, scope: :subject) { @subject.internal? }
rule { public_snippet }.policy do
enable :read_personal_snippet
enable :create_note
end
rule { is_author }.policy do
enable :read_personal_snippet
enable :update_personal_snippet
enable :destroy_personal_snippet
enable :admin_personal_snippet
enable :create_note
end
rule { ~anonymous }.enable :create_personal_snippet
rule { external_user }.prevent :create_personal_snippet
rule { internal_snippet & ~external_user }.policy do
enable :read_personal_snippet
enable :create_note
end
rule { anonymous }.prevent :create_note
rule { can?(:create_note) }.enable :award_emoji
rule { full_private_access }.enable :read_personal_snippet
end