v1.2.1+
This commit is contained in:
@@ -261,6 +261,12 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
return GetCodeTypeCaption(Sax.CodeType.OrganisationRole, organisationRole);
|
||||
}
|
||||
|
||||
// Event type.
|
||||
public String GetEventTypeCaption(Sax.EventType eventType)
|
||||
{
|
||||
return GetCodeTypeCaption(Sax.CodeType.EventType, eventType);
|
||||
}
|
||||
|
||||
// Opportunity type.
|
||||
public String GetOpportunityTypeCaption(Sax.OpportunityType opportunityType)
|
||||
{
|
||||
|
||||
@@ -75,21 +75,24 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
|
||||
if (!(new List<Sax.DataItemType>() { Sax.DataItemType.Sport, Sax.DataItemType.Region }).Contains(itemType))
|
||||
return candidateValue;
|
||||
|
||||
Dictionary<SysId, String> itemIds = data.encryptedIdCache.GetValue(itemType, null);
|
||||
if (itemIds == null)
|
||||
lock (data.encryptedIdCache)
|
||||
{
|
||||
// Add cache entry for this item type.
|
||||
itemIds = new Dictionary<SysId, string>();
|
||||
data.encryptedIdCache.Add(itemType, itemIds);
|
||||
Dictionary<SysId, String> itemIds = data.encryptedIdCache.GetValue(itemType, null);
|
||||
if (itemIds == null)
|
||||
{
|
||||
// Add cache entry for this item type.
|
||||
itemIds = new Dictionary<SysId, string>();
|
||||
data.encryptedIdCache.Add(itemType, itemIds);
|
||||
}
|
||||
String encryptedId = itemIds.GetValue(id, null);
|
||||
if (encryptedId == null && !StringUtil.IsEmpty(candidateValue))
|
||||
{
|
||||
// Use the candidate value and store it.
|
||||
encryptedId = candidateValue;
|
||||
itemIds.Add(id, encryptedId);
|
||||
}
|
||||
return encryptedId;
|
||||
}
|
||||
String encryptedId = itemIds.GetValue(id, null);
|
||||
if (encryptedId == null && !StringUtil.IsEmpty(candidateValue))
|
||||
{
|
||||
// Use the candidate value and store it.
|
||||
encryptedId = candidateValue;
|
||||
itemIds.Add(id, encryptedId);
|
||||
}
|
||||
return encryptedId;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
|
||||
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
|
||||
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
|
||||
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
|
||||
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
|
||||
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
|
||||
// Email.
|
||||
@@ -240,7 +241,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
// Copy the list of parameters, adding a random name/value pair to randomise the encryption.
|
||||
NameValueCollection parametersToEncrypt = new NameValueCollection(parameters);
|
||||
// NB Range 10-189 intended to have equal chance of 2 or 3 digit number.
|
||||
parametersToEncrypt.Add("!" + SacsRandomHelper.GetInt32(10, 190).ToString(), SacsRandomHelper.GetInt32(10, 190).ToString());
|
||||
parametersToEncrypt.Add("!" + SacsRandomHelper.getRandomLengthNumber(4), null);
|
||||
|
||||
// Sort the keys to ensure that the random '!' param is first in the query string.
|
||||
String[] paramKeys = parametersToEncrypt.AllKeys;
|
||||
@@ -249,11 +250,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
// Serialise parameters as if in a URL query string - so that they can be deserialised in DecryptParameters() below.
|
||||
string queryString = String.Join("&", paramKeys.Select(a => a + "=" + HttpUtility.UrlEncode(parametersToEncrypt[a])));
|
||||
String encrypted = SacsEncryptionHelper.Encrypt(queryString, base64IV, base64Key);
|
||||
if (SacsSystem.DebugMode)
|
||||
{
|
||||
SaLogger.Debug(fn + " Encrypted: " + encrypted);
|
||||
NameValueCollection decryptedParams = DecryptParameters(encrypted, base64IV, base64Key);
|
||||
}
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(fn + "\n\tData: " + queryString + " \n\tEncrypted: " + encrypted);
|
||||
return encrypted;
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(fn + " " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
@@ -262,10 +259,10 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
public static NameValueCollection DecryptParameters(String encrypted, String base64IV, String base64Key)
|
||||
{
|
||||
String fn = nameof(ControllerBase) + ".DecryptParameters";
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(fn + " \n\tEncrypted: " + encrypted + "\n\tIV: " + base64IV + "\n\tKey: " + base64Key);
|
||||
try
|
||||
{
|
||||
String queryString = SacsEncryptionHelper.Decrypt(encrypted, base64IV, base64Key);
|
||||
if (SacsSystem.DebugMode) SaLogger.Debug(fn + " \n\tEncrypted: " + encrypted + "\n\tData: " + queryString);
|
||||
return HttpUtility.ParseQueryString(queryString);
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Warn(fn + " " + ExceptionUtil.GetErrorStateMessage(exc)); }
|
||||
@@ -300,10 +297,12 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
// Session.
|
||||
//-------------------------------------------------------------------
|
||||
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
|
||||
public SysId UserAccountId { get { return SessionData?.User?.UserAccountId ?? null; } }
|
||||
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SaxSystem.ComputerName); } }
|
||||
// Referrer.
|
||||
public String Referer { get { return Request.Headers["Referer"].ToString(); } }
|
||||
public bool ValidReferer { get { return !StringUtil.IsEmpty(Referer); } }
|
||||
|
||||
/// <summary>Store session data, eg. to start a new user session on sign-in.</summary>
|
||||
protected bool SetSessionData(SaxSessionData sessionData)
|
||||
{
|
||||
|
||||
@@ -65,10 +65,10 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
protected SaxDataCacheConsole DataCacheConsole { get { return Internals.DataCacheConsole; } }
|
||||
protected SaxActivityConsole ActivityConsole { get { return Internals.ActivityConsole; } }
|
||||
// Managers.
|
||||
protected SaxReferenceMgr ReferenceMgr { get { return Internals.ReferenceMgr; } }
|
||||
protected SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
protected SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } }
|
||||
protected SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
|
||||
public SaxReferenceMgr ReferenceMgr { get { return Internals.ReferenceMgr; } }
|
||||
public SaxAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
public SaxActivityMgr ActivityMgr { get { return Internals.ActivityMgr; } }
|
||||
public SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
|
||||
// System codes.
|
||||
public List<TypeCodeDesc> DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } }
|
||||
public List<TypeCodeDesc> YesNoCodes { get { return Internals.YesNoCodes; } }
|
||||
@@ -81,6 +81,7 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
public List<TypeCodeDesc> OrganisationCategoryCodes { get { return Internals.OrganisationCategoryCodes; } }
|
||||
public List<TypeCodeDesc> OrganisationRoleCodes { get { return Internals.OrganisationRoleCodes; } }
|
||||
public List<TypeCodeDesc> AddressTypeCodes { get { return Internals.AddressTypeCodes; } }
|
||||
public List<TypeCodeDesc> EventTypeCodes { get { return Internals.EventTypeCodes; } }
|
||||
public List<TypeCodeDesc> OpportunityTypeCodes { get { return Internals.OpportunityTypeCodes; } }
|
||||
public List<TypeCodeDesc> ActivityReactionCodes { get { return Internals.ActivityReactionCodes; } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user