From: Tom Hughes Date: Mon, 6 May 2024 07:54:36 +0000 (+0100) Subject: Improve flash message handling in users#new X-Git-Tag: live~577^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/1874e5b1a2bd15bf165093dbaa147d5a9d8f898d?ds=sidebyside;hp=--cc Improve flash message handling in users#new 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. --- 1874e5b1a2bd15bf165093dbaa147d5a9d8f898d diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c3c4dcfb3..06df8f2be 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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