gitlab-org--gitlab-foss/app/policies/personal_snippet_policy.rb
Guyzmo fde754e267 API: Endpoint to expose personal snippets as /snippets
Adding the necessary API for the new /snippets Restful resource
added with this commit. Added a new Grape class `Snippets`, as
well as a `PersonalSnippet` entity.

Issue: #20042
Merge-Request: !6373
Signed-off-by: Guyzmo <guyzmo+gitlab+pub@m0g.net>
2016-12-01 19:07:49 +01:00

21 lines
483 B
Ruby

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
can! :destroy_personal_snippet
can! :admin_personal_snippet
end
unless @user.external?
can! :create_personal_snippet
end
if @subject.internal? && !@user.external?
can! :read_personal_snippet
end
end
end