aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_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/application_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/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index cb64cb922..cae3cb213 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -447,6 +447,17 @@ class ApplicationController < ActionController::Base
return query
end
+ def country_from_ip
+ gaze = MySociety::Config.get('GAZE_URL', '')
+ default = MySociety::Config.get('ISO_COUNTRY_CODE', '')
+ country = ""
+ if !gaze.empty?
+ country = open("#{gaze}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}").read.strip
+ end
+ country = default if country.empty?
+ return country
+ end
+
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.