Session persistent Security Profile

This commit is contained in:
Andy Howard
2025-01-23 12:50:53 +00:00
parent f375e0d175
commit 03b3a81dab
16 changed files with 557 additions and 233 deletions
@@ -95,7 +95,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
// Some actions (eg. score password) don't need to.
if (StoreSessionData)
{
String sessionDataJson = JsonConvert.SerializeObject(SessionData);
String sessionDataJson = JsonConvert.SerializeObject(SessionData, SbmController_Web.SessionDataJsonSerializerSettings);
HttpContext.Session.Set(SessionStorage.SessionKey_SessionData, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson));
}
}
@@ -189,15 +189,21 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
return base.CreateProperties(type, MemberSerialization.Fields);
}
};
public static JsonSerializerSettings JsonSerialisationSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
public static JsonSerializerSettings JsonDeserialisationSettings = new JsonSerializerSettings
{
ContractResolver = new SbmSessionDataContractResolver(),
// Force all deserialised objects to be replaced - to avoid proxy lists not populating.
ObjectCreationHandling = ObjectCreationHandling.Replace
ObjectCreationHandling = ObjectCreationHandling.Replace,
NullValueHandling = NullValueHandling.Ignore
};
}
private readonly SessionStorage sessionStorage = new SessionStorage();
public static JsonSerializerSettings SbmSessionDataJsonSerializerSettings { get { return SessionStorage.JsonDeserialisationSettings; } }
public static JsonSerializerSettings SessionDataJsonSerializerSettings { get { return SessionStorage.JsonSerialisationSettings; } }
public static JsonSerializerSettings SessionDataJsonDeserializerSettings { get { return SessionStorage.JsonDeserialisationSettings; } }
//-------------------------------------------------------------------
public SbmSessionData_Web SessionData