From 3955e96d344fc11de9cc5f28c65abe3b218815ef Mon Sep 17 00:00:00 2001 From: Daniel Valadas Date: Tue, 12 Oct 2021 20:13:09 -0400 Subject: [PATCH] Resoldved an issue with redirect tabIds on non-localized sites This is a follow up on #4851 All my testing had been done on a localized site and after having those settings exist in the database. @david-poindexter just found out it was problematic on a clean install as those settings simply do not exists and the code failed getting those settings values from the dictionary of settings. This PR solves that. --- .../Services/SiteSettingsController.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/SiteSettingsController.cs b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/SiteSettingsController.cs index f59e7ef0963..5ba9d72314b 100644 --- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/SiteSettingsController.cs +++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/SiteSettingsController.cs @@ -319,11 +319,11 @@ public HttpResponseMessage GetDefaultPagesSettings(int? portalId, string culture } var portal = PortalController.Instance.GetPortal(pid, cultureCode); - var localizedPortalSettings = PortalController.Instance.GetPortalSettings(portal.PortalID, cultureCode); + var localizedPortalSettings = PortalController.Instance.GetPortalSettings(pid, cultureCode); - int redirectAfterLoginTabId = int.TryParse(localizedPortalSettings["Redirect_AfterLogin"], out redirectAfterLoginTabId) ? redirectAfterLoginTabId : -1; - int redirectAfterLogoutTabId = int.TryParse(localizedPortalSettings["Redirect_AfterLogout"], out redirectAfterLogoutTabId) ? redirectAfterLogoutTabId : -1; - int redirectAfterRegistrationTabId = int.TryParse(localizedPortalSettings["Redirect_AfterRegistration"], out redirectAfterRegistrationTabId) ? redirectAfterRegistrationTabId : -1; + int redirectAfterLoginTabId = this.GetLocalizedTabIdSetting(localizedPortalSettings, "Redirect_AfterLogin"); + int redirectAfterLogoutTabId = this.GetLocalizedTabIdSetting(localizedPortalSettings, "Redirect_AfterLogout"); + int redirectAfterRegistrationTabId = this.GetLocalizedTabIdSetting(localizedPortalSettings, "Redirect_AfterRegistration"); return this.Request.CreateResponse(HttpStatusCode.OK, new { @@ -3582,5 +3582,17 @@ private int ValidateTabId(int tabId, int portalId) var tab = TabController.Instance.GetTab(tabId, portalId); return tab != null && !tab.IsDeleted ? tab.TabID : Null.NullInteger; } + + private int GetLocalizedTabIdSetting(Dictionary localizedPortalSettings, string settingKey) + { + var settingValue = string.Empty; + if (localizedPortalSettings.TryGetValue(settingKey, out settingValue)) + { + int tabId = int.TryParse(settingValue, out tabId) ? tabId : -1; + return tabId; + } + + return -1; + } } }