diff --git a/Interface/Support/DashboardMessage.cs b/Interface/Support/DashboardMessage.cs
new file mode 100644
index 00000000..1c6ab14b
--- /dev/null
+++ b/Interface/Support/DashboardMessage.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace Swarmops.Interface.Support
+{
+ public class DashboardMessage
+ {
+ public static void Set (string localizedMessage)
+ {
+ CheckContext();
+
+ HttpCookie setMessage = new HttpCookie("DashboardMessage", Uri.EscapeDataString (localizedMessage).Replace ("+", "%20").Replace ("'", "%27"));
+ setMessage.Expires = DateTime.Now.AddDays(7);
+
+ HttpContext.Current.Response.SetCookie(setMessage);
+ }
+
+ public static void Reset()
+ {
+ CheckContext();
+
+ HttpCookie clearMessage = new HttpCookie ("DashboardMessage", string.Empty);
+ clearMessage.Expires = DateTime.Now.AddYears(-10);
+
+ HttpContext.Current.Response.SetCookie(clearMessage);
+ }
+
+ private static void CheckContext()
+ {
+ if (HttpContext.Current == null)
+ {
+ throw new InvalidOperationException("No active HttpContext");
+ }
+ }
+ }
+}
diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs
index 28887c73..793600cc 100644
--- a/Site5/Master-v5.master.cs
+++ b/Site5/Master-v5.master.cs
@@ -9,6 +9,7 @@ using System.Web;
using System.Web.Security;
using System.Web.UI;
using Resources;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
@@ -155,9 +156,8 @@ namespace Swarmops
if (dashMessage != null && dashMessage.Value.Length > 0)
{
this.LiteralDocumentReadyHook.Text =
- string.Format ("alertify.alert(unescape('{0}'.replace(/\\+/g, '%20')));", dashMessage.Value);
- Response.SetCookie (new HttpCookie ("DashboardMessage", string.Empty));
- Response.Cookies["DashboardMessage"].Expires = DateTime.Now.AddYears (-10);
+ string.Format ("alertify.alert(decodeURIComponent('{0}'));", dashMessage.Value);
+ DashboardMessage.Reset();
}
else
{
diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs
index bc5189d3..8339b513 100644
--- a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs
+++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.Web;
using System.Web.UI.WebControls;
using Resources;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Swarm;
@@ -129,7 +130,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
string successMessage = String.Format (Resources.Pages.Admin.CreateOrganization_Success,
Participant.Localized (peopleLabel, TitleVariant.Ship));
- Response.AppendCookie (new HttpCookie ("DashboardMessage", HttpUtility.UrlEncode (successMessage)));
+ DashboardMessage.Set (successMessage);
// Log in to new organization, then redirect to Edit
diff --git a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs
index b09eb81d..134709c7 100644
--- a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs
+++ b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Web;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Support;
@@ -212,7 +213,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
claim.Attest (CurrentUser);
}
- Response.AppendCookie (new HttpCookie ("DashboardMessage", HttpUtility.UrlEncode (successMessage)));
+ DashboardMessage.Set (successMessage);
// Redirect to dashboard
diff --git a/Site5/Pages/v5/Financial/RequestCashAdvance.aspx.cs b/Site5/Pages/v5/Financial/RequestCashAdvance.aspx.cs
index 43f6642f..074b7a1d 100644
--- a/Site5/Pages/v5/Financial/RequestCashAdvance.aspx.cs
+++ b/Site5/Pages/v5/Financial/RequestCashAdvance.aspx.cs
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.Web;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
@@ -108,7 +109,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
cashAdvance.Attest (CurrentUser);
}
- Response.AppendCookie (new HttpCookie ("DashboardMessage", HttpUtility.UrlEncode (successMessage)));
+ DashboardMessage.Set (successMessage);
// Redirect to dashboard
diff --git a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
index 5db02b5d..0fc438db 100644
--- a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
@@ -16,6 +16,7 @@ using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
+using Swarmops.Interface.Support;
// TODO: There are significant remnants in this file from the old Telerik-based upload code. When Account Automation is complete and the user can select a bank profile
// for an account, uploading payment files as well as bank statements, remove that dead code as its templates won't be needed after that.
@@ -62,9 +63,7 @@ namespace Swarmops.Site.Pages.Ledgers
if (!supportedHardcode)
{
- Response.AppendCookie (new HttpCookie ("DashboardMessage",
- HttpUtility.UrlEncode (
- "There are no asset accounts set up for automation, so no accounts support data upload at this time. Returning to Dashboard.")));
+ DashboardMessage.Set ("There are no asset accounts set up for automation, so no accounts support data upload at this time. Returning to Dashboard.");
Response.Redirect ("/", true);
}
diff --git a/Site5/Security/Login-Old.aspx.cs b/Site5/Security/Login-Old.aspx.cs
index a7941ef4..19bc5250 100644
--- a/Site5/Security/Login-Old.aspx.cs
+++ b/Site5/Security/Login-Old.aspx.cs
@@ -7,6 +7,7 @@ using System.Web.UI;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Swarm;
using Swarmops.Database;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Security;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
@@ -30,9 +31,7 @@ namespace Swarmops.Pages.Security
if (Request.Url.Host == "dev.swarmops.com" &&
PilotInstallationIds.IsPilot (PilotInstallationIds.DevelopmentSandbox))
{
- Response.AppendCookie (new HttpCookie ("DashboardMessage",
- HttpUtility.UrlEncode (
- "You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.
This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.
In other words, welcome, and play away!
")));
+ DashboardMessage.Set ("You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.
This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.
In other words, welcome, and play away!
");
FormsAuthentication.RedirectFromLoginPage ("1,1", true);
}
diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs
index f3780257..cfcc5d61 100644
--- a/Site5/Security/Login.aspx.cs
+++ b/Site5/Security/Login.aspx.cs
@@ -10,6 +10,7 @@ using System.Web.UI;
using NBitcoin;
using Resources;
using Swarmops.Database;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
@@ -78,9 +79,7 @@ namespace Swarmops.Pages.Security
PilotInstallationIds.IsPilot (PilotInstallationIds.DevelopmentSandbox) &&
Request.QueryString["SuppressAutologin"] != "true")
{
- Response.AppendCookie (new HttpCookie ("DashboardMessage",
- HttpUtility.UrlEncode (
- "You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.
This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.
In other words, welcome, and play away!
")));
+ DashboardMessage.Set ("You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.
This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.
In other words, welcome, and play away!
");
FormsAuthentication.SetAuthCookie ("1,1", true);
Response.Redirect ("/");
}
@@ -91,9 +90,9 @@ namespace Swarmops.Pages.Security
if (organizationOpenLedgers != null)
{
- Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(String.Format(Resources.Pages.Security.Login_AsOpenLedgers, organizationOpenLedgers.Name))));
+ DashboardMessage.Set (String.Format(Resources.Pages.Security.Login_AsOpenLedgers, organizationOpenLedgers.Name));
FormsAuthentication.SetAuthCookie(Person.OpenLedgersIdentity.ToString() + "," + organizationOpenLedgers.Identity.ToString(), true);
- Response.Redirect ("/Ledgers/BalanceSheet");
+ Response.Redirect (@"/Ledgers/BalanceSheet");
}
// Check for SSL and force it
diff --git a/Site5/Security/ResetPassword.aspx.cs b/Site5/Security/ResetPassword.aspx.cs
index 381d965c..73305279 100644
--- a/Site5/Security/ResetPassword.aspx.cs
+++ b/Site5/Security/ResetPassword.aspx.cs
@@ -9,6 +9,7 @@ using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using NBitcoin.BouncyCastle.Asn1.Ocsp;
+using Swarmops.Interface.Support;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Transmission;
using Swarmops.Logic.Structure;
@@ -135,7 +136,7 @@ namespace Swarmops.Pages.Security
// Set cookies
FormsAuthentication.SetAuthCookie(resetPerson.Identity.ToString(CultureInfo.InvariantCulture) + "," + lastOrgId.ToString(CultureInfo.InvariantCulture) + ",,AuthPlain", true);
- HttpContext.Current.Response.SetCookie (new HttpCookie ("DashboardMessage", Resources.Pages.Security.ResetPassword_Success));
+ DashboardMessage.Set (Resources.Pages.Security.ResetPassword_Success);
return true; // temp