Skip to content

Commit

Permalink
Resoldved an issue with redirect tabIds on non-localized sites
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
valadas authored and bdukes committed Oct 13, 2021
1 parent 04c10fb commit 3955e96
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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<string, string> 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;
}
}
}

0 comments on commit 3955e96

Please # to comment.