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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 03:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 03:08:51 +0300
commit1ce6af4aad0107b6d604f89a3c0b530476a10165 (patch)
tree4956b0d395cd9232bca14f83daca3cd8616cc842 /app/controllers/import
parent24256212ea84e6fb6509f6fb317a2d2bac3d0d06 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/import')
-rw-r--r--app/controllers/import/base_controller.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
index 9b45be6db99..f16f752f85b 100644
--- a/app/controllers/import/base_controller.rb
+++ b/app/controllers/import/base_controller.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
class Import::BaseController < ApplicationController
+ before_action :import_rate_limit, only: [:create]
+
private
# rubocop: disable CodeReuse/ActiveRecord
@@ -37,4 +39,18 @@ class Import::BaseController < ApplicationController
def project_save_error(project)
project.errors.full_messages.join(', ')
end
+
+ def import_rate_limit
+ key = "project_import".to_sym
+
+ if rate_limiter.throttled?(key, scope: [current_user, key])
+ rate_limiter.log_request(request, "#{key}_request_limit".to_sym, current_user)
+
+ redirect_back_or_default(options: { alert: _('This endpoint has been requested too many times. Try again later.') })
+ end
+ end
+
+ def rate_limiter
+ ::Gitlab::ApplicationRateLimiter
+ end
end