aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/user_controller.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-08-30 13:29:25 +0100
committerSeb Bacon <seb.bacon@gmail.com>2011-08-30 13:29:25 +0100
commita8d0c217e68fdac0331c0d80df511e5340a67fb7 (patch)
treec8c286107dcec99399635f78533ba74764cc96a0 /app/controllers/user_controller.rb
parent9d8388c03d0faeaca29d233a340c58bd65f28a97 (diff)
Present a reCaptcha on the signup form to foreign visitors (judging from their IP address). Fixes #157 (at least as a starter).
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r--app/controllers/user_controller.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index d3c42c7f1..cd46b6ea4 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -118,10 +118,15 @@ class UserController < ApplicationController
# Create new account form
def signup
work_out_post_redirect
-
+ @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB')
# Make the user and try to save it
@user_signup = User.new(params[:user_signup])
- if !@user_signup.valid?
+ error = false
+ if @request_from_foreign_country && !verify_recaptcha
+ flash.now[:error] = _("There was an error with the words you entered, please try again.")
+ error = true
+ end
+ if error || !@user_signup.valid?
# Show the form
render :action => 'sign'
else