FIX: send email to normalized email owner when hiding emails (#23524)

Previous to this change when both `normalize_emails` and `hide_email_address_taken`
is enabled the expected `account_exists` email was only sent on exact email
matches.

This expands it so it also sends an email to the canonical email owner.
This commit is contained in:
Sam
2023-09-12 11:06:35 +10:00
committed by GitHub
parent 80dcaf1e98
commit b3bef96744
3 changed files with 56 additions and 3 deletions

View File

@ -767,7 +767,12 @@ class UsersController < ApplicationController
user.errors[:primary_email]&.include?(I18n.t("errors.messages.taken"))
session["user_created_message"] = activation.success_message
if existing_user = User.find_by_email(user.primary_email&.email)
existing_user = User.find_by_email(user.primary_email&.email)
if !existing_user && SiteSetting.normalize_emails
existing_user =
UserEmail.find_by_normalized_email(user.primary_email&.normalized_email)&.user
end
if existing_user
Jobs.enqueue(:critical_user_email, type: "account_exists", user_id: existing_user.id)
end