mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Reverting changes, validate email only if it was provided
This commit is contained in:
@@ -50,11 +50,11 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpPut("~/api/v1/server/email")]
|
||||
public async Task<IActionResult> ServerEmailSettings(ServerEmailSettingsData request)
|
||||
{
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(request.From))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(request.From) && !MailboxAddressValidator.IsMailboxAddress(request.From))
|
||||
ModelState.AddModelError(nameof(request.From), "Invalid email address");
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return this.CreateValidationError(ModelState);
|
||||
}
|
||||
|
||||
if (_policiesSettings.DisableStoresToUseServerEmailSettings == request.EnableStoresToUseServerEmailSettings)
|
||||
{
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpPut("~/api/v1/stores/{storeId}/email")]
|
||||
public async Task<IActionResult> UpdateStoreEmailSettings(string storeId, EmailSettingsData request)
|
||||
{
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(request.From))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(request.From) && !MailboxAddressValidator.IsMailboxAddress(request.From))
|
||||
ModelState.AddModelError(nameof(request.From), "Invalid email address");
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return this.CreateValidationError(ModelState);
|
||||
}
|
||||
|
||||
var store = HttpContext.GetStoreData();
|
||||
var blob = store.GetStoreBlob();
|
||||
|
||||
@@ -1256,8 +1256,8 @@ namespace BTCPayServer.Controllers
|
||||
return RedirectToAction(nameof(Emails));
|
||||
}
|
||||
|
||||
// save
|
||||
if (!MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
// save if user provided valid email; this will also clear settings if no model.Settings.From
|
||||
if (model.Settings.From is not null && !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 (!MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
if (model.Settings.From is not null && !MailboxAddressValidator.IsMailboxAddress(model.Settings.From))
|
||||
{
|
||||
ModelState.AddModelError("Settings.From", StringLocalizer["Invalid email"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user