Merge pull request #2585 from sbwalker/dev

refactor visitor cookie name into a shared constant
This commit is contained in:
Shaun Walker 2023-02-07 16:25:05 -05:00 committed by GitHub
commit eb876845ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 4 deletions

View File

@ -237,7 +237,7 @@ else
protected override void OnAfterRender(bool firstRender)
{
if (!firstRender)
if (firstRender)
{
// external link to log item will display Details component
if (PageState.QueryString.ContainsKey("id") && int.TryParse(PageState.QueryString["id"], out int id))

View File

@ -46,7 +46,7 @@ namespace Oqtane.Controllers
_identityCache = identityCache;
_logger = logger;
_alias = tenantManager.GetAlias();
_visitorCookie = "APP_VISITOR_" + _alias.SiteId.ToString();
_visitorCookie = Constants.VisitorCookiePrefix + _alias.SiteId.ToString();
}
// GET: api/<controller>

View File

@ -50,7 +50,7 @@ namespace Oqtane.Controllers
bool authorized = User.IsInRole(RoleNames.Admin);
if (!authorized)
{
var visitorCookie = "APP_VISITOR_" + _alias.SiteId.ToString();
var visitorCookie = Constants.VisitorCookiePrefix + _alias.SiteId.ToString();
if (int.TryParse(Request.Cookies[visitorCookie], out int visitorId))
{
authorized = (visitorId == id);

View File

@ -284,7 +284,7 @@ namespace Oqtane.Pages
// check if cookie already exists
Visitor visitor = null;
bool addcookie = false;
var VisitorCookie = "APP_VISITOR_" + SiteId.ToString();
var VisitorCookie = Constants.VisitorCookiePrefix + SiteId.ToString();
if (!int.TryParse(Request.Cookies[VisitorCookie], out VisitorId))
{
// if enabled use IP Address correlation

View File

@ -73,6 +73,7 @@ namespace Oqtane.Shared
public static readonly string HttpContextSiteSettingsKey = "SiteSettings";
public static readonly string MauiUserAgent = "MAUI";
public static readonly string VisitorCookiePrefix = "APP_VISITOR_";
// Obsolete constants