From 778f9cb356d7c3df7bb974fcf321956b3b9db9af Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Tue, 5 Jan 2021 16:57:36 -0500 Subject: [PATCH] added better validaton and user feedback related to SMTP configuration --- Oqtane.Client/Modules/Admin/Site/Index.razor | 29 ++++++++++++------- .../Infrastructure/Jobs/NotificationJob.cs | 9 ++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 3910ab9b..ddf17450 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -129,9 +129,14 @@
+ + +
+ @Localizer["Please Note That SMTP Requires The Notification Job To Be Enabled In the Scheduled Jobs"] +
- + @@ -139,7 +144,7 @@
- + @@ -147,15 +152,18 @@
- + - +
- + @@ -163,7 +171,7 @@
- + @@ -205,7 +213,6 @@
- @Localizer["Cancel"]

@@ -232,7 +239,7 @@ private string _allowregistration; private string _smtphost = string.Empty; private string _smtpport = string.Empty; - private string _smtpssl = string.Empty; + private string _smtpssl = "False"; private string _smtpusername = string.Empty; private string _smtppassword = string.Empty; private string _pwaisenabled; @@ -287,7 +294,7 @@ var settings = await SettingService.GetSiteSettingsAsync(site.SiteId); _smtphost = SettingService.GetSetting(settings, "SMTPHost", string.Empty); _smtpport = SettingService.GetSetting(settings, "SMTPPort", string.Empty); - _smtpssl = SettingService.GetSetting(settings, "SMTPSSL", string.Empty); + _smtpssl = SettingService.GetSetting(settings, "SMTPSSL", "False"); _smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty); _smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty); @@ -437,9 +444,9 @@ SettingService.SetSetting(settings, "SMTPPassword", _smtppassword); await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId); - await logger.LogInformation("Site Saved {Site}", site); + await logger.LogInformation("Site Settings Saved {Site}", site); - NavigationManager.NavigateTo(NavigateUrl()); + AddModuleMessage(Localizer["Site Settings Saved"], MessageType.Success); } } else diff --git a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs index 2e18950f..404829d7 100644 --- a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs +++ b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -47,7 +47,10 @@ namespace Oqtane.Infrastructure // get site settings List sitesettings = settingRepository.GetSettings(EntityNames.Site, site.SiteId).ToList(); Dictionary settings = GetSettings(sitesettings); - if (settings.ContainsKey("SMTPHost") && settings["SMTPHost"] != "") + if (settings.ContainsKey("SMTPHost") && settings["SMTPHost"] != "" && + settings.ContainsKey("SMTPPort") && settings["SMTPPort"] != "" && + settings.ContainsKey("SMTPSSL") && settings["SMTPSSL"] != "" && + settings.ContainsKey("SMTPUsername") && settings["SMTPUsername"] != "") { // construct SMTP Client var client = new SmtpClient() @@ -112,7 +115,7 @@ namespace Oqtane.Infrastructure } else { - log += "SMTP Not Configured" + "
"; + log += "SMTP Not Configured Properly In Site Settings - Host, Port, SSL, And Username Are All Required" + "
"; } } }