summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/spammable_actions.rb
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/concerns/spammable_actions.rb
parent9429e8ac60a10436a0469d7d206d3f74a2c966c7 (diff)
downloadgitlab-ce-1a3b292d350cc4c226066562d489432e7f37e105.tar.gz
Resolve "No feedback when checking on checklist if potential spam was detected"
Diffstat (limited to 'app/controllers/concerns/spammable_actions.rb')
-rw-r--r--app/controllers/concerns/spammable_actions.rb17
1 files changed, 14 insertions, 3 deletions
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