summaryrefslogtreecommitdiff
path: root/app/controllers/projects/issues_controller.rb
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-01-27 17:25:39 +0100
committerJarka Kadlecova <jarka@gitlab.com>2017-02-07 12:56:20 +0100
commit3d2954e4570d236a080b0d46698d96a28fd9acec (patch)
tree0295eec45b4589fc55a1cf587eb7c1cd98d8c9ce /app/controllers/projects/issues_controller.rb
parent999edc5c1783aa205fdac4ba159e51851acdb446 (diff)
downloadgitlab-ce-3d2954e4570d236a080b0d46698d96a28fd9acec.tar.gz
Use reCaptcha when an issue identified as spam
Diffstat (limited to 'app/controllers/projects/issues_controller.rb')
-rw-r--r--app/controllers/projects/issues_controller.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 8472ceca329..c75b8987a4b 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -93,15 +93,13 @@ class Projects::IssuesController < Projects::ApplicationController
def create
extra_params = { request: request,
merge_request_for_resolving_discussions: merge_request_for_resolving_discussions }
+ extra_params.merge!(recaptcha_params)
+
@issue = Issues::CreateService.new(project, current_user, issue_params.merge(extra_params)).execute
respond_to do |format|
format.html do
- if @issue.valid?
- redirect_to issue_path(@issue)
- else
- render :new
- end
+ html_response_create
end
format.js do
@link = @issue.attachment.url.to_js
@@ -178,6 +176,20 @@ class Projects::IssuesController < Projects::ApplicationController
protected
+ def html_response_create
+ if @issue.valid?
+ redirect_to issue_path(@issue)
+ elsif render_recaptcha?
+ if params[:recaptcha_verification]
+ flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ end
+
+ render :verify
+ else
+ render :new
+ end
+ end
+
def issue
# The Sortable default scope causes performance issues when used with find_by
@noteable = @issue ||= @project.issues.where(iid: params[:id]).reorder(nil).take || redirect_old