diff --git a/Core/Main/PTMagicConfiguration.cs b/Core/Main/PTMagicConfiguration.cs
index 7d29d14..64eda87 100644
--- a/Core/Main/PTMagicConfiguration.cs
+++ b/Core/Main/PTMagicConfiguration.cs
@@ -83,6 +83,25 @@ namespace Core.Main
return result;
}
+ public string GetProfitTrailerServerAPITokenMasked()
+ {
+ string result = "";
+
+ if (!this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Equals(""))
+ {
+ result = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(0, 4);
+
+ for (int i = 1; i < this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 8; i++)
+ {
+ result += "*";
+ }
+
+ result += this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 4);
+ }
+
+ return result;
+ }
+
public GeneralSettings GeneralSettings
{
get
diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml
index 64c3783..bc00c54 100644
--- a/Monitor/Pages/SettingsGeneral.cshtml
+++ b/Monitor/Pages/SettingsGeneral.cshtml
@@ -92,7 +92,7 @@
diff --git a/Monitor/Pages/SetupPassword.cshtml b/Monitor/Pages/SetupPassword.cshtml
index 7c2f9d0..e99989b 100644
--- a/Monitor/Pages/SetupPassword.cshtml
+++ b/Monitor/Pages/SetupPassword.cshtml
@@ -14,29 +14,30 @@
PT Magic
Setup your password.
-
diff --git a/Monitor/Pages/SetupPassword.cshtml.cs b/Monitor/Pages/SetupPassword.cshtml.cs
index eb53c5f..54e75c9 100644
--- a/Monitor/Pages/SetupPassword.cshtml.cs
+++ b/Monitor/Pages/SetupPassword.cshtml.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Core.Main;
+using Core.Helper;
namespace Monitor.Pages
{
@@ -16,19 +17,39 @@ namespace Monitor.Pages
base.PreInit();
}
- public void OnPost(string password, string passwordConfirm)
+ public void OnPost(string OldPassword, string Password, string PasswordConfirm)
{
- if (!password.Equals(passwordConfirm))
+ base.PreInit();
+ ValidationMessage = "Test";
+ string encryptedOldPassword = null;
+
+ if (OldPassword != null)
{
- ValidationMessage = "Password does not match the confirmation!";
+ encryptedOldPassword = EncryptionHelper.Encrypt(OldPassword);
+
+ if (!Password.Equals(PasswordConfirm) || !encryptedOldPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword) && System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "settings.secure.json"))
+ {
+ 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");
+ }
}
-
- if (ModelState.IsValid)
+ else
{
- base.PreInit();
- PTMagicConfiguration.WriteSecureSettings(password);
-
- Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
+ if (!Password.Equals(PasswordConfirm) && !System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "settings.secure.json"))
+ {
+ ValidationMessage = "New Password does not match with confirmation";
+ }
+ else if (ModelState.IsValid)
+ {
+ PTMagicConfiguration.WriteSecureSettings(Password);
+ ValidationMessage = "";
+ Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
+ }
}
}