From: Tom Hughes Date: Mon, 8 Feb 2010 18:04:04 +0000 (+0000) Subject: Handle duplicate address errors properly when confirming a change of X-Git-Tag: live~6383^2~42 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/d24312fa8c79a370faa33c23c9bf3719c9931857?hp=4aa4aaf0e15fb3eaf1ce80734b793a5c3543523c Handle duplicate address errors properly when confirming a change of email address. --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ca0046762..2f22ad940 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -73,6 +73,14 @@ class UserController < ApplicationController flash.now[:notice] = t 'user.account.flash update success' end end + else + if flash[:errors] + flash[:errors].each do |attr,msg| + @user.errors.add(attr,msg) + end + end + + @user.email = @user.new_email if @user.new_email end end @@ -227,9 +235,12 @@ class UserController < ApplicationController @user.new_email = nil @user.active = true @user.email_valid = true - @user.save! + if @user.save + flash[:notice] = t 'user.confirm_email.success' + else + flash[:errors] = @user.errors + end token.destroy - flash[:notice] = t 'user.confirm_email.success' session[:user] = @user.id redirect_to :action => 'account', :display_name => @user.display_name else