X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/7c25a1e1bc05af8110fd2d81a6db208b01a0eacb..49038a44d9876d6766e30deb2ff56bf4bde78af7:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index de07e4b53..3f5eef831 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -23,9 +23,7 @@ class UserController < ApplicationController @text = OSM.legal_text_for_country(@legale) if request.xhr? - render :update do |page| - page.replace_html "contributorTerms", :partial => "terms" - end + render :partial => "terms" elsif using_open_id? # The redirect from the OpenID provider reenters here # again and we need to pass the parameters through to @@ -188,13 +186,6 @@ class UserController < ApplicationController openid_verify(nil, @user) do |user| update_user(user) end - else - if flash[:errors] - flash[:errors].each do |attr,msg| - attr = "new_email" if attr == "email" and !@user.new_email.nil? - @user.errors.add(attr,msg) - end - end end end @@ -659,16 +650,25 @@ private if user.save set_locale - if user.new_email.nil? or user.new_email.empty? + if user.new_email.blank? flash.now[:notice] = t 'user.account.flash update success' else - flash.now[:notice] = t 'user.account.flash update success confirm needed' + user.email = user.new_email - begin - Notifier.email_confirm(user, user.tokens.create).deliver - rescue - # Ignore errors sending email + if user.valid? + flash.now[:notice] = t 'user.account.flash update success confirm needed' + + begin + Notifier.email_confirm(user, user.tokens.create).deliver + rescue + # Ignore errors sending email + end + else + @user.errors.set(:new_email, @user.errors.get(:email)) + @user.errors.set(:email, []) end + + user.reset_email! end end end