gitlab-org--gitlab-foss/app/policies/project_snippet_policy.rb
Timothy Andrew 2e0e2b22d6
Backport changes from gitlab-org/gitlab-ee!998
Some changes in EE for the auditor user feature need
to be backported to CE to avoid merge conflicts. This
commit encapsulates all these backports.
2017-02-06 01:17:33 +05:30

20 lines
502 B
Ruby

class ProjectSnippetPolicy < BasePolicy
def rules
can! :read_project_snippet if @subject.public?
return unless @user
if @user && (@subject.author == @user || @user.admin?)
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