BigW Consortium Gitlab

personal_snippet_policy.rb 483 Bytes
Newer Older
1 2 3 4 5 6 7 8
class PersonalSnippetPolicy < BasePolicy
  def rules
    can! :read_personal_snippet if @subject.public?
    return unless @user

    if @subject.author == @user
      can! :read_personal_snippet
      can! :update_personal_snippet
9
      can! :destroy_personal_snippet
10 11 12
      can! :admin_personal_snippet
    end

13 14 15 16
    unless @user.external?
      can! :create_personal_snippet
    end

17 18 19 20 21
    if @subject.internal? && !@user.external?
      can! :read_personal_snippet
    end
  end
end