Welcome to mirror list, hosted at ThFree Co, Russian Federation.

controller_with_cross_project_access_check.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f72f0926830c3ab003d00882d40fe4e62cf039d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module ControllerWithCrossProjectAccessCheck
  extend ActiveSupport::Concern

  included do
    extend Gitlab::CrossProjectAccess::ClassMethods
    before_action :cross_project_check
  end

  def cross_project_check
    if Gitlab::CrossProjectAccess.find_check(self)&.should_run?(self)
      authorize_cross_project_page!
    end
  end

  def authorize_cross_project_page!
    return if can?(current_user, :read_cross_project)

    rejection_message = _(
      "This page is unavailable because you are not allowed to read information "\
      "across multiple projects."
    )
    access_denied!(rejection_message)
  end
end