From 465dce1d026156754cb664281d32e4bb993d751c Mon Sep 17 00:00:00 2001 From: rockstardev Date: Mon, 4 Mar 2019 15:56:23 -0600 Subject: [PATCH] Running check of submitted SMTP data on both Test and Save --- BTCPayServer/Controllers/ServerController.cs | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index 4d8713fdd..a9f50f692 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -427,13 +427,6 @@ namespace BTCPayServer.Controllers } public IHttpClientFactory HttpClientFactory { get; } - [Route("server/emails")] - public async Task Emails() - { - var data = (await _SettingsRepository.GetSettingAsync()) ?? new EmailSettings(); - return View(new EmailsViewModel() { Settings = data }); - } - [Route("server/policies")] public async Task Policies() { @@ -690,19 +683,28 @@ namespace BTCPayServer.Controllers return View(settings); } + + [Route("server/emails")] + public async Task Emails() + { + var data = (await _SettingsRepository.GetSettingAsync()) ?? new EmailSettings(); + return View(new EmailsViewModel() { Settings = data }); + } + [Route("server/emails")] [HttpPost] public async Task Emails(EmailsViewModel model, string command) { + if (!model.Settings.IsComplete()) + { + model.StatusMessage = "Error: Required fields missing"; + return View(model); + } + if (command == "Test") { try { - if (!model.Settings.IsComplete()) - { - model.StatusMessage = "Error: Required fields missing"; - return View(model); - } var client = model.Settings.CreateSmtpClient(); await client.SendMailAsync(model.Settings.From, model.TestEmail, "BTCPay test", "BTCPay test"); model.StatusMessage = "Email sent to " + model.TestEmail + ", please, verify you received it";