From b76ae638462ab0f673e5915986070518dd3f9ad3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 19 Aug 2021 09:08:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-2-stable-ee --- app/views/shared/_captcha_check.html.haml | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/views/shared/_captcha_check.html.haml (limited to 'app/views/shared/_captcha_check.html.haml') diff --git a/app/views/shared/_captcha_check.html.haml b/app/views/shared/_captcha_check.html.haml new file mode 100644 index 00000000000..3d611c22491 --- /dev/null +++ b/app/views/shared/_captcha_check.html.haml @@ -0,0 +1,37 @@ +- resource_name = spammable.class.model_name.singular +- humanized_resource_name = spammable.class.model_name.human.downcase +- script = local_assigns.fetch(:script, true) +- method = params[:action] == 'create' ? :post : :put + +%h3.page-title + = _('Anti-spam verification') +%hr + +%p + = _("We detected potential spam in the %{humanized_resource_name}. Please solve the reCAPTCHA to proceed.") % { humanized_resource_name: humanized_resource_name } + += form_for resource_name, method: method, html: { class: 'recaptcha-form js-recaptcha-form' } do |f| + .recaptcha + -# Create a hidden field for each param of the resource + - params[resource_name].each do |field, value| + = hidden_field(resource_name, field, value: value) + + -# The reCAPTCHA response value will be returned in the 'g-recaptcha-response' field in non-test environments + = recaptcha_tags script: script, callback: 'recaptchaDialogCallback', nonce: content_security_policy_nonce unless Rails.env.test? + + -# Fake the 'g-recaptcha-response' field in the test environment, so that the feature spec + -# can get to the (mocked) SpamVerdictService check. + = hidden_field_tag('g-recaptcha-response', 'abc123') if Rails.env.test? + + -# Create a hidden field to pass back the ID of the spam_log record which was previously created + = hidden_field_tag(:spam_log_id, spammable.spam_log.id) + + -# Yields a block with given extra params which are not included in `params[resource_name]`. + -# Currently, this is only used for these params which are passed via URL parameters, + -# and can be removed once they are no longer needed to be passed: + -# - merge_request_to_resolve_discussions_of + -# - discussion_to_resolve + = yield + + .row-content-block.footer-block + = f.submit _("Create %{humanized_resource_name}") % { humanized_resource_name: humanized_resource_name }, class: 'gl-button btn btn-confirm' -- cgit v1.2.1