BigW Consortium Gitlab

project_snippet_policy.rb 502 Bytes
Newer Older
1 2 3 4 5
class ProjectSnippetPolicy < BasePolicy
  def rules
    can! :read_project_snippet if @subject.public?
    return unless @user

6
    if @user && (@subject.author == @user || @user.admin?)
7 8 9 10 11 12 13 14 15 16 17 18 19 20
      can! :read_project_snippet
      can! :update_project_snippet
      can! :admin_project_snippet
    end

    if @subject.internal? && !@user.external?
      can! :read_project_snippet
    end

    if @subject.private? && @subject.project.team.member?(@user)
      can! :read_project_snippet
    end
  end
end