diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-09-16 12:43:27 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-09-16 12:43:27 +0100 |
commit | 312f9e1191dd4d7d0e976728561c4b74d8b84588 (patch) | |
tree | 506a615c2bbb95cf7f30a1655ef6ccd7e2d2f521 /app/controllers/user_controller.rb | |
parent | 8a0210db99a146a2700a5db0335618423ea756a0 (diff) | |
parent | d54f405434a3b0da5f2c88fc065680caf044aff2 (diff) |
Merge branch 'release/0.3'0.3
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r-- | app/controllers/user_controller.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d3c42c7f1..6916b4456 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -24,7 +24,7 @@ class UserController < ApplicationController @display_user = User.find(:first, :conditions => [ "url_name = ? and email_confirmed = ?", params[:url_name], true ]) if not @display_user - raise "user not found, url_name=" + params[:url_name] + raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name]) end @same_name_users = User.find(:all, :conditions => [ "name ilike ? and email_confirmed = ? and id <> ?", @display_user.name, true, @display_user.id ], :order => "created_at") @@ -71,7 +71,7 @@ class UserController < ApplicationController # Login form def signin work_out_post_redirect - + @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB') # make sure we have cookies if session.instance_variable_get(:@dbman) if not session.instance_variable_get(:@dbman).instance_variable_get(:@original) @@ -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 @@ -133,7 +138,6 @@ class UserController < ApplicationController # New unconfirmed user @user_signup.email_confirmed = false @user_signup.save! - send_confirmation_mail @user_signup return end @@ -454,7 +458,7 @@ class UserController < ApplicationController def get_profile_photo @display_user = User.find(:first, :conditions => [ "url_name = ? and email_confirmed = ?", params[:url_name], true ]) if !@display_user - raise "user not found, url_name=" + params[:url_name] + raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name]) end if !@display_user.profile_photo raise "user has no profile photo, url_name=" + params[:url_name] |