summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorLuke Bennett <lbennett@gitlab.com>2017-12-08 12:26:39 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-12-08 12:26:39 +0000
commit1a3b292d350cc4c226066562d489432e7f37e105 (patch)
tree39a1cc2dfd39acfdc606d754028fe2e2de00a3cf /app/controllers
parent9429e8ac60a10436a0469d7d206d3f74a2c966c7 (diff)
downloadgitlab-ce-1a3b292d350cc4c226066562d489432e7f37e105.tar.gz
Resolve "No feedback when checking on checklist if potential spam was detected"
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/concerns/issuable_actions.rb2
-rw-r--r--app/controllers/concerns/spammable_actions.rb17
2 files changed, 15 insertions, 4 deletions
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index 744e448e8df..ecac9be0360 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -25,7 +25,7 @@ module IssuableActions
end
format.json do
- render_entity_json
+ recaptcha_check_with_fallback(false) { render_entity_json }
end
end
diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb
index ada0dde87fb..03d8e188093 100644
--- a/app/controllers/concerns/spammable_actions.rb
+++ b/app/controllers/concerns/spammable_actions.rb
@@ -23,8 +23,8 @@ module SpammableActions
@spam_config_loaded = Gitlab::Recaptcha.load_configurations!
end
- def recaptcha_check_with_fallback(&fallback)
- if spammable.valid?
+ def recaptcha_check_with_fallback(should_redirect = true, &fallback)
+ if should_redirect && spammable.valid?
redirect_to spammable_path
elsif render_recaptcha?
ensure_spam_config_loaded!
@@ -33,7 +33,18 @@ module SpammableActions
flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
end
- render :verify
+ respond_to do |format|
+ format.html do
+ render :verify
+ end
+
+ format.json do
+ locals = { spammable: spammable, script: false, has_submit: false }
+ recaptcha_html = render_to_string(partial: 'shared/recaptcha_form', formats: :html, locals: locals)
+
+ render json: { recaptcha_html: recaptcha_html }
+ end
+ end
else
yield
end