Add email blacklist and refactor email validity checks

This commit is contained in:
FeTetra 2024-12-16 19:42:05 -05:00
commit 980a2af3c6
7 changed files with 71 additions and 23 deletions

View file

@ -65,17 +65,13 @@ public class UserSettingsPage : BaseLayout
}
if (ServerConfiguration.Instance.Mail.MailEnabled &&
SanitizationHelper.IsValidEmail(email) &&
SMTPHelper.IsValidEmail(this.Database, email) &&
(this.User == this.ProfileUser || this.User.IsAdmin))
{
// if email hasn't already been used
if (!await this.Database.Users.AnyAsync(u => u.EmailAddress != null && u.EmailAddress.ToLower() == email!.ToLower()))
if (this.ProfileUser.EmailAddress != email)
{
if (this.ProfileUser.EmailAddress != email)
{
this.ProfileUser.EmailAddress = email;
this.ProfileUser.EmailAddressVerified = false;
}
this.ProfileUser.EmailAddress = email;
this.ProfileUser.EmailAddressVerified = false;
}
}