]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Merge branch 'master' into openid
[rails.git] / app / controllers / user_controller.rb
index 1ac3b1ca53321202c2dc4242b77ac9f253c39cac..d456c1353ef9f45a230927d09a804f61f0ba1cd4 100644 (file)
@@ -55,8 +55,14 @@ class UserController < ApplicationController
 
       if @user
         if @user.invalid?
-          # Something is wrong, so rerender the form
-          render :action => :new
+          if @user.new_record?
+            # Something is wrong with a new user, so rerender the form
+            render :action => :new
+          else
+            # Error in existing user, so go to account settings
+            flash[:errors] = @user.errors
+            redirect_to :action => :account, :display_name => @user.display_name
+          end
         elsif @user.terms_agreed?
           # Already agreed to terms, so just show settings
           redirect_to :action => :account, :display_name => @user.display_name
@@ -153,6 +159,13 @@ 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