mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
IsMailboxAddress already checks for null, simplifying code
This commit is contained in:
@@ -306,14 +306,12 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
{
|
||||
if (request.Email is null)
|
||||
ModelState.AddModelError(nameof(request.Email), "Email is missing");
|
||||
if (!string.IsNullOrEmpty(request.Email) && !MailboxAddressValidator.IsMailboxAddress(request.Email))
|
||||
{
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(request.Email))
|
||||
ModelState.AddModelError(nameof(request.Email), "Invalid email");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return this.CreateValidationError(ModelState);
|
||||
}
|
||||
|
||||
if (User.Identity is null)
|
||||
throw new JsonHttpException(this.StatusCode(401));
|
||||
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
|
||||
|
||||
@@ -1257,7 +1257,7 @@ namespace BTCPayServer.Controllers
|
||||
}
|
||||
|
||||
// save
|
||||
if (model.Settings.From is not null && !MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
{
|
||||
ModelState.AddModelError("Settings.From", StringLocalizer["Invalid email"]);
|
||||
return View(model);
|
||||
|
||||
@@ -209,7 +209,7 @@ public partial class UIStoresController
|
||||
if (model.IsCustomSMTP)
|
||||
{
|
||||
model.Settings.Validate("Settings.", ModelState);
|
||||
if (model.Settings.From is not null && !MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
{
|
||||
ModelState.AddModelError("Settings.From", StringLocalizer["Invalid email"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user