summaryrefslogtreecommitdiff
path: root/app/controllers/projects/snippets/application_controller.rb
blob: b8faf464531552f4ac6106039f32740a4ad47688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class Projects::Snippets::ApplicationController < Projects::ApplicationController
  include FindSnippet
  include SnippetAuthorizations

  feature_category :source_code_management

  private

  # This overrides the default snippet create authorization
  # because ProjectSnippets are checked against the project rather
  # than the user
  def authorize_create_snippet!
    return render_404 unless can?(current_user, :create_snippet, project)
  end

  def snippet_klass
    ProjectSnippet
  end
end