mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Fix: Unable to reset email settings (#6963)
This commit is contained in:
@@ -79,8 +79,6 @@ public class UIStoresEmailController(
|
|||||||
{
|
{
|
||||||
ModelState.AddModelError("Settings.From", StringLocalizer["Invalid email"]);
|
ModelState.AddModelError("Settings.From", StringLocalizer["Invalid email"]);
|
||||||
}
|
}
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return View(model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var storeBlob = store.GetStoreBlob();
|
var storeBlob = store.GetStoreBlob();
|
||||||
@@ -88,6 +86,9 @@ public class UIStoresEmailController(
|
|||||||
if (model is { IsCustomSMTP: true, Settings: { Password: null } })
|
if (model is { IsCustomSMTP: true, Settings: { Password: null } })
|
||||||
model.Settings.Password = currentSettings?.Password;
|
model.Settings.Password = currentSettings?.Password;
|
||||||
|
|
||||||
|
if (!ModelState.IsValid && command is not ("ResetPassword" or "mailpit"))
|
||||||
|
return View(model);
|
||||||
|
|
||||||
if (command == "Test")
|
if (command == "Test")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -61,27 +61,17 @@ namespace BTCPayServer.Services.Mails
|
|||||||
{
|
{
|
||||||
return MailboxAddressValidator.IsMailboxAddress(From)
|
return MailboxAddressValidator.IsMailboxAddress(From)
|
||||||
&& !string.IsNullOrWhiteSpace(Server)
|
&& !string.IsNullOrWhiteSpace(Server)
|
||||||
&& Port != null;
|
&& Port != null
|
||||||
|
&& !string.IsNullOrWhiteSpace(From)
|
||||||
|
&& MailboxAddressValidator.IsMailboxAddress(From);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Validate(string prefixKey, ModelStateDictionary modelState)
|
public void Validate(string prefixKey, ModelStateDictionary modelState)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(From))
|
if (!string.IsNullOrEmpty(From) && !MailboxAddressValidator.IsMailboxAddress(From))
|
||||||
{
|
|
||||||
modelState.AddModelError($"{prefixKey}{nameof(From)}", new RequiredAttribute().FormatErrorMessage(nameof(From)));
|
|
||||||
}
|
|
||||||
if (!MailboxAddressValidator.IsMailboxAddress(From))
|
|
||||||
{
|
{
|
||||||
modelState.AddModelError($"{prefixKey}{nameof(From)}", MailboxAddressAttribute.ErrorMessageConst);
|
modelState.AddModelError($"{prefixKey}{nameof(From)}", MailboxAddressAttribute.ErrorMessageConst);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(Server))
|
|
||||||
{
|
|
||||||
modelState.AddModelError($"{prefixKey}{nameof(Server)}", new RequiredAttribute().FormatErrorMessage(nameof(Server)));
|
|
||||||
}
|
|
||||||
if (Port is null)
|
|
||||||
{
|
|
||||||
modelState.AddModelError($"{prefixKey}{nameof(Port)}", new RequiredAttribute().FormatErrorMessage(nameof(Port)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MimeMessage CreateMailMessage(MailboxAddress to, string subject, string message, bool isHtml) =>
|
public MimeMessage CreateMailMessage(MailboxAddress to, string subject, string message, bool isHtml) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user