From 24a50dd24444d64fd01eee6bf5f4133b9e7614f8 Mon Sep 17 00:00:00 2001 From: JackTerok Date: Sat, 20 Feb 2021 20:26:22 +0100 Subject: [PATCH] implement proper messages on error --- Monitor/Pages/SetupPassword.cshtml | 5 +++++ Monitor/Pages/SetupPassword.cshtml.cs | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Monitor/Pages/SetupPassword.cshtml b/Monitor/Pages/SetupPassword.cshtml index 643f1b7..e99989b 100644 --- a/Monitor/Pages/SetupPassword.cshtml +++ b/Monitor/Pages/SetupPassword.cshtml @@ -45,6 +45,11 @@ +
+
+ @Model.ValidationMessage +
+
diff --git a/Monitor/Pages/SetupPassword.cshtml.cs b/Monitor/Pages/SetupPassword.cshtml.cs index 0d93fd6..54e75c9 100644 --- a/Monitor/Pages/SetupPassword.cshtml.cs +++ b/Monitor/Pages/SetupPassword.cshtml.cs @@ -20,7 +20,7 @@ namespace Monitor.Pages public void OnPost(string OldPassword, string Password, string PasswordConfirm) { base.PreInit(); - + ValidationMessage = "Test"; string encryptedOldPassword = null; if (OldPassword != null) @@ -29,11 +29,12 @@ namespace Monitor.Pages if (!Password.Equals(PasswordConfirm) || !encryptedOldPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword) && System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "settings.secure.json")) { - Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "SetupPassword"); + ValidationMessage = "Old Password wrong or new Password does not match with confirmation"; } else if (ModelState.IsValid) { PTMagicConfiguration.WriteSecureSettings(Password); + ValidationMessage = ""; Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login"); } } @@ -41,11 +42,12 @@ namespace Monitor.Pages { if (!Password.Equals(PasswordConfirm) && !System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "settings.secure.json")) { - Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "SetupPassword"); + ValidationMessage = "New Password does not match with confirmation"; } else if (ModelState.IsValid) { PTMagicConfiguration.WriteSecureSettings(Password); + ValidationMessage = ""; Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login"); } }