Improve email settings validation and UX (#3891)

This commit is contained in:
Nicolas Dorier
2022-06-23 13:41:52 +09:00
committed by GitHub
parent c2d72e71aa
commit c89f7aaaed
26 changed files with 161 additions and 93 deletions

View File

@@ -39,7 +39,7 @@ namespace BTCPayServer.Controllers.GreenField
{
return this.CreateAPIError(404, "store-not-found", "The store was not found");
}
if (!MailboxAddress.TryParse(request.Email, out MailboxAddress to))
if (!MailboxAddressValidator.TryParse(request.Email, out var to))
{
ModelState.AddModelError(nameof(request.Email), "Invalid email");
return this.CreateValidationError(ModelState);
@@ -72,7 +72,7 @@ namespace BTCPayServer.Controllers.GreenField
return StoreNotFound();
}
if (!string.IsNullOrEmpty(request.From) && !EmailValidator.IsEmail(request.From))
if (!string.IsNullOrEmpty(request.From) && !MailboxAddressValidator.IsMailboxAddress(request.From))
{
request.AddModelError(e => e.From,
"Invalid email address", this);