]> git.openstreetmap.org Git - rails.git/commitdiff
Improve flash message handling in users#new
authorTom Hughes <tom@compton.nu>
Mon, 6 May 2024 07:54:36 +0000 (08:54 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 6 May 2024 08:14:49 +0000 (09:14 +0100)
Only show the duplicate email message if we actually have errors
logged against the email field, and then show it as a warning.

In all other cases we show the generic informational hint about
social logins and pre-existing accounts.

app/controllers/users_controller.rb

index c3c4dcfb3e81b260c9a65b5193c174f541f35fc8..06df8f2be074e587f6624545ce71c7183cc441ea 100644 (file)
@@ -78,10 +78,11 @@ class UsersController < ApplicationController
                                    :auth_provider => params[:auth_provider],
                                    :auth_uid => params[:auth_uid])
 
-      flash.now[:notice] = render_to_string :partial => "auth_association"
-
-      # validate before displaying to show email field if it conflicts
-      flash.now[:notice] = t ".duplicate_social_email" unless current_user.valid? && current_user.errors[:email].empty?
+      if current_user.valid? || current_user.errors[:email].empty?
+        flash.now[:notice] = render_to_string :partial => "auth_association"
+      else
+        flash.now[:warning] = t ".duplicate_social_email"
+      end
     else
       check_signup_allowed