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.
This commit is contained in:
Tom Hughes 2024-05-06 08:54:36 +01:00
parent 4965c19b7a
commit 1874e5b1a2

View file

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