Commit be1be2c4 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'move-controller-prepends' into 'master'

Move EE prepend/include to the end of controllers

See merge request gitlab-org/gitlab-ee!8201
parents 71cf8df0 d12d9834
# frozen_string_literal: true # frozen_string_literal: true
class Admin::AppearancesController < Admin::ApplicationController class Admin::AppearancesController < Admin::ApplicationController
prepend EE::Admin::AppearancesController
before_action :set_appearance, except: :create before_action :set_appearance, except: :create
def show def show
...@@ -79,3 +77,5 @@ class Admin::AppearancesController < Admin::ApplicationController ...@@ -79,3 +77,5 @@ class Admin::AppearancesController < Admin::ApplicationController
] ]
end end
end end
Admin::AppearancesController.prepend(EE::Admin::AppearancesController)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
class Admin::ApplicationSettingsController < Admin::ApplicationController class Admin::ApplicationSettingsController < Admin::ApplicationController
include InternalRedirect include InternalRedirect
prepend EE::Admin::ApplicationSettingsController
before_action :set_application_setting before_action :set_application_setting
def show def show
...@@ -135,3 +133,5 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -135,3 +133,5 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
] ]
end end
end end
Admin::ApplicationSettingsController.prepend(EE::Admin::ApplicationSettingsController)
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
class Admin::GroupsController < Admin::ApplicationController class Admin::GroupsController < Admin::ApplicationController
include MembersPresentation include MembersPresentation
prepend EE::Admin::GroupsController
before_action :group, only: [:edit, :update, :destroy, :project_update, :members_update] before_action :group, only: [:edit, :update, :destroy, :project_update, :members_update]
def index def index
...@@ -95,3 +93,5 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -95,3 +93,5 @@ class Admin::GroupsController < Admin::ApplicationController
] ]
end end
end end
Admin::GroupsController.prepend(EE::Admin::GroupsController)
# frozen_string_literal: true # frozen_string_literal: true
class Admin::LogsController < Admin::ApplicationController class Admin::LogsController < Admin::ApplicationController
prepend EE::Admin::LogsController
before_action :loggers before_action :loggers
def show def show
...@@ -21,3 +19,5 @@ class Admin::LogsController < Admin::ApplicationController ...@@ -21,3 +19,5 @@ class Admin::LogsController < Admin::ApplicationController
] ]
end end
end end
Admin::LogsController.prepend(EE::Admin::LogsController)
# frozen_string_literal: true # frozen_string_literal: true
class Admin::UsersController < Admin::ApplicationController class Admin::UsersController < Admin::ApplicationController
prepend EE::Admin::UsersController
before_action :user, except: [:index, :new, :create] before_action :user, except: [:index, :new, :create]
def index def index
...@@ -230,3 +228,5 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -230,3 +228,5 @@ class Admin::UsersController < Admin::ApplicationController
result[:status] == :success result[:status] == :success
end end
end end
Admin::UsersController.prepend(EE::Admin::UsersController)
# frozen_string_literal: true # frozen_string_literal: true
class AutocompleteController < ApplicationController class AutocompleteController < ApplicationController
prepend EE::AutocompleteController
skip_before_action :authenticate_user!, only: [:users, :award_emojis] skip_before_action :authenticate_user!, only: [:users, :award_emojis]
def users def users
...@@ -41,3 +39,5 @@ class AutocompleteController < ApplicationController ...@@ -41,3 +39,5 @@ class AutocompleteController < ApplicationController
render json: AwardedEmojiFinder.new(current_user).execute render json: AwardedEmojiFinder.new(current_user).execute
end end
end end
AutocompleteController.prepend(EE::AutocompleteController)
# frozen_string_literal: true # frozen_string_literal: true
module InternalRedirect module InternalRedirect
prepend EE::InternalRedirect
extend ActiveSupport::Concern extend ActiveSupport::Concern
def safe_redirect_path(path) def safe_redirect_path(path)
...@@ -46,3 +45,5 @@ module InternalRedirect ...@@ -46,3 +45,5 @@ module InternalRedirect
URI(request.referer).path URI(request.referer).path
end end
end end
InternalRedirect.prepend(EE::InternalRedirect)
# frozen_string_literal: true # frozen_string_literal: true
module IssuableActions module IssuableActions
prepend EE::IssuableActions
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
...@@ -227,3 +226,5 @@ module IssuableActions ...@@ -227,3 +226,5 @@ module IssuableActions
@project || @group # rubocop:disable Gitlab/ModuleWithInstanceVariables @project || @group # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
end end
IssuableActions.prepend(EE::IssuableActions)
# frozen_string_literal: true # frozen_string_literal: true
module IssuableCollections module IssuableCollections
prepend EE::IssuableCollections
extend ActiveSupport::Concern extend ActiveSupport::Concern
include CookiesHelper include CookiesHelper
include SortingHelper include SortingHelper
...@@ -179,3 +178,5 @@ module IssuableCollections ...@@ -179,3 +178,5 @@ module IssuableCollections
end end
end end
end end
IssuableCollections.prepend(EE::IssuableCollections)
...@@ -15,7 +15,6 @@ module LfsRequest ...@@ -15,7 +15,6 @@ module LfsRequest
CONTENT_TYPE = 'application/vnd.git-lfs+json'.freeze CONTENT_TYPE = 'application/vnd.git-lfs+json'.freeze
included do included do
prepend EE::LfsRequest
before_action :require_lfs_enabled! before_action :require_lfs_enabled!
before_action :lfs_check_access! before_action :lfs_check_access!
end end
...@@ -124,3 +123,5 @@ module LfsRequest ...@@ -124,3 +123,5 @@ module LfsRequest
(authentication_abilities || []).include?(capability) (authentication_abilities || []).include?(capability)
end end
end end
LfsRequest.prepend(EE::LfsRequest)
# frozen_string_literal: true # frozen_string_literal: true
module ProjectUnauthorized module ProjectUnauthorized
prepend EE::ProjectUnauthorized
extend ActiveSupport::Concern extend ActiveSupport::Concern
# EE would override this # EE would override this
...@@ -10,3 +8,5 @@ module ProjectUnauthorized ...@@ -10,3 +8,5 @@ module ProjectUnauthorized
# no-op # no-op
end end
end end
ProjectUnauthorized.prepend(EE::ProjectUnauthorized)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
module ServiceParams module ServiceParams
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepend EE::ServiceParams
ALLOWED_PARAMS_CE = [ ALLOWED_PARAMS_CE = [
:active, :active,
:add_pusher, :add_pusher,
...@@ -86,3 +84,5 @@ module ServiceParams ...@@ -86,3 +84,5 @@ module ServiceParams
ALLOWED_PARAMS_CE ALLOWED_PARAMS_CE
end end
end end
ServiceParams.prepend(EE::ServiceParams)
# frozen_string_literal: true # frozen_string_literal: true
class Groups::ApplicationController < ApplicationController class Groups::ApplicationController < ApplicationController
prepend EE::Groups::ApplicationController
include RoutableActions include RoutableActions
include ControllerWithCrossProjectAccessCheck include ControllerWithCrossProjectAccessCheck
...@@ -39,3 +38,5 @@ class Groups::ApplicationController < ApplicationController ...@@ -39,3 +38,5 @@ class Groups::ApplicationController < ApplicationController
url_for(safe_params) url_for(safe_params)
end end
end end
Groups::ApplicationController.prepend(EE::Groups::ApplicationController)
# frozen_string_literal: true # frozen_string_literal: true
class Groups::BoardsController < Groups::ApplicationController class Groups::BoardsController < Groups::ApplicationController
prepend EE::Boards::BoardsController
include BoardsResponses include BoardsResponses
before_action :assign_endpoint_vars before_action :assign_endpoint_vars
...@@ -51,3 +50,5 @@ class Groups::BoardsController < Groups::ApplicationController ...@@ -51,3 +50,5 @@ class Groups::BoardsController < Groups::ApplicationController
end end
end end
end end
Groups::BoardsController.prepend(EE::Boards::BoardsController)
# frozen_string_literal: true # frozen_string_literal: true
class Groups::GroupMembersController < Groups::ApplicationController class Groups::GroupMembersController < Groups::ApplicationController
prepend EE::Groups::GroupMembersController
include MembershipActions include MembershipActions
include MembersPresentation include MembersPresentation
include SortingHelper include SortingHelper
...@@ -45,3 +43,5 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -45,3 +43,5 @@ class Groups::GroupMembersController < Groups::ApplicationController
# MembershipActions concern # MembershipActions concern
alias_method :membershipable, :group alias_method :membershipable, :group
end end
Groups::GroupMembersController.prepend(EE::Groups::GroupMembersController)
# frozen_string_literal: true # frozen_string_literal: true
class Groups::MilestonesController < Groups::ApplicationController class Groups::MilestonesController < Groups::ApplicationController
prepend EE::Groups::MilestonesController
include MilestoneActions include MilestoneActions
before_action :group_projects before_action :group_projects
...@@ -115,3 +113,5 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -115,3 +113,5 @@ class Groups::MilestonesController < Groups::ApplicationController
params.permit(:state).merge(group_ids: group.id) params.permit(:state).merge(group_ids: group.id)
end end
end end
Groups::MilestonesController.prepend(EE::Groups::MilestonesController)
...@@ -6,8 +6,6 @@ class GroupsController < Groups::ApplicationController ...@@ -6,8 +6,6 @@ class GroupsController < Groups::ApplicationController
include MergeRequestsAction include MergeRequestsAction
include ParamsBackwardCompatibility include ParamsBackwardCompatibility
include PreviewMarkdown include PreviewMarkdown
prepend EE::GroupsController
respond_to :html respond_to :html
before_action :authenticate_user!, only: [:new, :create] before_action :authenticate_user!, only: [:new, :create]
...@@ -199,3 +197,5 @@ class GroupsController < Groups::ApplicationController ...@@ -199,3 +197,5 @@ class GroupsController < Groups::ApplicationController
url_for(safe_params) url_for(safe_params)
end end
end end
GroupsController.prepend(EE::GroupsController)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
class Ldap::OmniauthCallbacksController < OmniauthCallbacksController class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
prepend EE::OmniauthCallbacksController
prepend EE::Ldap::OmniauthCallbacksController
def self.define_providers! def self.define_providers!
return unless Gitlab::Auth::LDAP::Config.enabled? return unless Gitlab::Auth::LDAP::Config.enabled?
...@@ -33,3 +31,6 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController ...@@ -33,3 +31,6 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
redirect_to new_user_session_path redirect_to new_user_session_path
end end
end end
Ldap::OmniauthCallbacksController.prepend(EE::OmniauthCallbacksController)
Ldap::OmniauthCallbacksController.prepend(EE::Ldap::OmniauthCallbacksController)
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
class OmniauthCallbacksController < Devise::OmniauthCallbacksController class OmniauthCallbacksController < Devise::OmniauthCallbacksController
include AuthenticatesWithTwoFactor include AuthenticatesWithTwoFactor
include Devise::Controllers::Rememberable include Devise::Controllers::Rememberable
prepend EE::OmniauthCallbacksController
protect_from_forgery except: [:kerberos, :saml, :cas3], prepend: true protect_from_forgery except: [:kerberos, :saml, :cas3], prepend: true
def handle_omniauth def handle_omniauth
...@@ -201,3 +199,5 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -201,3 +199,5 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
(request_params['remember_me'] == '1') if request_params.present? (request_params['remember_me'] == '1') if request_params.present?
end end
end end
OmniauthCallbacksController.prepend(EE::OmniauthCallbacksController)
...@@ -7,8 +7,6 @@ class PasswordsController < Devise::PasswordsController ...@@ -7,8 +7,6 @@ class PasswordsController < Devise::PasswordsController
before_action :check_password_authentication_available, only: [:create] before_action :check_password_authentication_available, only: [:create]
before_action :throttle_reset, only: [:create] before_action :throttle_reset, only: [:create]
prepend EE::PasswordsController
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def edit def edit
super super
...@@ -66,3 +64,5 @@ class PasswordsController < Devise::PasswordsController ...@@ -66,3 +64,5 @@ class PasswordsController < Devise::PasswordsController
notice: I18n.t('devise.passwords.send_paranoid_instructions') notice: I18n.t('devise.passwords.send_paranoid_instructions')
end end
end end
PasswordsController.prepend(EE::PasswordsController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::BoardsController < Projects::ApplicationController class Projects::BoardsController < Projects::ApplicationController
prepend EE::Boards::BoardsController
include BoardsResponses include BoardsResponses
include IssuableCollections include IssuableCollections
...@@ -59,3 +58,5 @@ class Projects::BoardsController < Projects::ApplicationController ...@@ -59,3 +58,5 @@ class Projects::BoardsController < Projects::ApplicationController
end end
end end
end end
Projects::BoardsController.prepend(EE::Boards::BoardsController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::ClustersController < Clusters::ClustersController class Projects::ClustersController < Clusters::ClustersController
prepend EE::Projects::ClustersController
include ProjectUnauthorized include ProjectUnauthorized
prepend_before_action :project prepend_before_action :project
...@@ -24,3 +22,5 @@ class Projects::ClustersController < Clusters::ClustersController ...@@ -24,3 +22,5 @@ class Projects::ClustersController < Clusters::ClustersController
@repository ||= project.repository @repository ||= project.repository
end end
end end
Projects::ClustersController.prepend(EE::Projects::ClustersController)
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
class Projects::MirrorsController < Projects::ApplicationController class Projects::MirrorsController < Projects::ApplicationController
include RepositorySettingsRedirect include RepositorySettingsRedirect
prepend EE::Projects::MirrorsController
# Authorize # Authorize
before_action :remote_mirror, only: [:update] before_action :remote_mirror, only: [:update]
before_action :check_mirror_available! before_action :check_mirror_available!
...@@ -87,3 +85,5 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -87,3 +85,5 @@ class Projects::MirrorsController < Projects::ApplicationController
params.require(:project).permit(mirror_params_attributes) params.require(:project).permit(mirror_params_attributes)
end end
end end
Projects::MirrorsController.prepend(EE::Projects::MirrorsController)
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
module Projects module Projects
module Prometheus module Prometheus
class MetricsController < Projects::ApplicationController class MetricsController < Projects::ApplicationController
prepend EE::Projects::Prometheus::MetricsController
before_action :authorize_admin_project! before_action :authorize_admin_project!
before_action :require_prometheus_metrics! before_action :require_prometheus_metrics!
...@@ -34,3 +32,5 @@ module Projects ...@@ -34,3 +32,5 @@ module Projects
end end
end end
end end
Projects::Prometheus::MetricsController.prepend(EE::Projects::Prometheus::MetricsController)
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
module Projects module Projects
module Settings module Settings
class IntegrationsController < Projects::ApplicationController class IntegrationsController < Projects::ApplicationController
prepend EE::Projects::Settings::IntegrationsController
include ServiceParams include ServiceParams
before_action :authorize_admin_project! before_action :authorize_admin_project!
...@@ -27,3 +25,5 @@ module Projects ...@@ -27,3 +25,5 @@ module Projects
end end
end end
end end
Projects::Settings::IntegrationsController.prepend(EE::Projects::Settings::IntegrationsController)
...@@ -6,8 +6,6 @@ class ProjectsController < Projects::ApplicationController ...@@ -6,8 +6,6 @@ class ProjectsController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
include PreviewMarkdown include PreviewMarkdown
include SendFileUpload include SendFileUpload
prepend EE::ProjectsController
before_action :whitelist_query_limiting, only: [:create] before_action :whitelist_query_limiting, only: [:create]
before_action :authenticate_user!, except: [:index, :show, :activity, :refs] before_action :authenticate_user!, except: [:index, :show, :activity, :refs]
before_action :redirect_git_extension, only: [:show] before_action :redirect_git_extension, only: [:show]
...@@ -449,3 +447,5 @@ class ProjectsController < Projects::ApplicationController ...@@ -449,3 +447,5 @@ class ProjectsController < Projects::ApplicationController
@project = @project.present(current_user: current_user) @project = @project.present(current_user: current_user)
end end
end end
ProjectsController.prepend(EE::ProjectsController)
...@@ -4,8 +4,6 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -4,8 +4,6 @@ class RegistrationsController < Devise::RegistrationsController
include Recaptcha::Verify include Recaptcha::Verify
include AcceptsPendingInvitations include AcceptsPendingInvitations
prepend EE::RegistrationsController
before_action :whitelist_query_limiting, only: [:destroy] before_action :whitelist_query_limiting, only: [:destroy]
before_action :ensure_terms_accepted, before_action :ensure_terms_accepted,
if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms? }, if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms? },
...@@ -121,3 +119,5 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -121,3 +119,5 @@ class RegistrationsController < Devise::RegistrationsController
Gitlab::Utils.to_boolean(params[:terms_opt_in]) Gitlab::Utils.to_boolean(params[:terms_opt_in])
end end
end end
RegistrationsController.prepend(EE::RegistrationsController)
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
# For users who haven't customized the setting, we simply delegate to # For users who haven't customized the setting, we simply delegate to
# `DashboardController#show`, which is the default. # `DashboardController#show`, which is the default.
class RootController < Dashboard::ProjectsController class RootController < Dashboard::ProjectsController
prepend EE::RootController
skip_before_action :authenticate_user!, only: [:index] skip_before_action :authenticate_user!, only: [:index]
before_action :redirect_unlogged_user, if: -> { current_user.nil? } before_action :redirect_unlogged_user, if: -> { current_user.nil? }
...@@ -64,3 +62,5 @@ class RootController < Dashboard::ProjectsController ...@@ -64,3 +62,5 @@ class RootController < Dashboard::ProjectsController
root_urls.exclude?(home_page_url) root_urls.exclude?(home_page_url)
end end
end end
RootController.prepend(EE::RootController)
# frozen_string_literal: true # frozen_string_literal: true
class SentNotificationsController < ApplicationController class SentNotificationsController < ApplicationController
prepend EE::SentNotificationsController
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
def unsubscribe def unsubscribe
...@@ -38,3 +36,5 @@ class SentNotificationsController < ApplicationController ...@@ -38,3 +36,5 @@ class SentNotificationsController < ApplicationController
end end
end end
end end
SentNotificationsController.prepend(EE::SentNotificationsController)
...@@ -6,8 +6,6 @@ class SessionsController < Devise::SessionsController ...@@ -6,8 +6,6 @@ class SessionsController < Devise::SessionsController
include Devise::Controllers::Rememberable include Devise::Controllers::Rememberable
include Recaptcha::ClientHelper include Recaptcha::ClientHelper
include Recaptcha::Verify include Recaptcha::Verify
prepend EE::SessionsController
skip_before_action :check_two_factor_requirement, only: [:destroy] skip_before_action :check_two_factor_requirement, only: [:destroy]
prepend_before_action :check_initial_setup, only: [:new] prepend_before_action :check_initial_setup, only: [:new]
...@@ -220,3 +218,5 @@ class SessionsController < Devise::SessionsController ...@@ -220,3 +218,5 @@ class SessionsController < Devise::SessionsController
end end
end end
end end
SessionsController.prepend(EE::SessionsController)
...@@ -4,8 +4,6 @@ class UsersController < ApplicationController ...@@ -4,8 +4,6 @@ class UsersController < ApplicationController
include RoutableActions include RoutableActions
include RendersMemberAccess include RendersMemberAccess
include ControllerWithCrossProjectAccessCheck include ControllerWithCrossProjectAccessCheck
prepend EE::UsersController
requires_cross_project_access show: false, requires_cross_project_access show: false,
groups: false, groups: false,
projects: false, projects: false,
...@@ -165,3 +163,5 @@ class UsersController < ApplicationController ...@@ -165,3 +163,5 @@ class UsersController < ApplicationController
access_denied! unless can?(current_user, :read_user_profile, user) access_denied! unless can?(current_user, :read_user_profile, user)
end end
end end
UsersController.prepend(EE::UsersController)
...@@ -13,6 +13,10 @@ module EE ...@@ -13,6 +13,10 @@ module EE
end end
prepended do prepended do
# This before_action needs to be redefined so we can use the new values
# from `admin_not_required_endpoints`.
before_action :authorize_admin_group_member!, except: admin_not_required_endpoints
before_action :authorize_update_group_member!, only: [:update, :override] before_action :authorize_update_group_member!, only: [:update, :override]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment