summaryrefslogtreecommitdiff
path: root/app/views/shared/_captcha_check.html.haml
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/views/shared/_captcha_check.html.haml
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/views/shared/_captcha_check.html.haml')
-rw-r--r--app/views/shared/_captcha_check.html.haml37
1 files changed, 37 insertions, 0 deletions
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'