This commit is contained in:
2022-05-29 13:45:22 +01:00
parent d631ad0223
commit 833798c9f8
93 changed files with 2063 additions and 788 deletions
@@ -15,6 +15,7 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace Saxonite.Net.Core.Web.Admin.Controllers
{
@@ -119,6 +120,21 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
ClearSessionData();
}
//-------------------------------------------------------------------
// Organisation utilities.
//-------------------------------------------------------------------
/// <summary>
/// Construct URL to display Organisation logo.
/// <para>- Option to allow for 'Upload' image if active.</para>
/// </summary>
protected String GetOrganisationLogoUrl(SysId organisationId, bool uploadImage)
{
String imageLink = "Image/Organisation/Logo" + (uploadImage ? "/Upload" : "") + "?";
NameValueCollection parameters = new NameValueCollection();
parameters.Add(ImageController.ParamName_OrganisationId, SysId.ToString(organisationId));
return imageLink + ImageController.ParamName_OrganisationLogoEncrypted + "=" + EncryptSessionParams(parameters);
}
//-------------------------------------------------------------------
// Keep Logged In.
//-------------------------------------------------------------------
@@ -187,6 +203,25 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
return keepLoggedInParams;
}
//-------------------------------------------------------------------
// Parameter encryption, eg. for images.
//-------------------------------------------------------------------
// Encryption key is the same for all users each time the application is started,
// but a different IV value is generated for each session so that the links/parameters cannot be shared.
public static String Base64Key_AdminApp { get; } = SacsEncryptionHelper.EncodePlainKey("Saxonite&Admin#Encryption-"+DateTime.Today.Format("ddMMyy"), SacsEncryptionHelper.KeyLength);
protected String EncryptSessionParams(NameValueCollection parameters)
{
return HttpUtility.UrlEncode(EncryptParameters(parameters, SessionData_Admin.Base64IV_AdminApp, Base64Key_AdminApp));
}
public static String EncryptSessionParams(SaxController_Admin controller, NameValueCollection parameters)
{
return controller.EncryptSessionParams(parameters);
}
protected NameValueCollection ExtractSessionParams(String encryptedParams)
{
return DecryptParameters(encryptedParams, SessionData_Admin.Base64IV_AdminApp, Base64Key_AdminApp);
}
//-------------------------------------------------------------------
}
//=======================================================================