diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index bee52ca..0083de6 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -35,7 +35,6 @@ namespace Core.Main.DataObjects.PTMagicData public bool IsEnabled { get; set; } = true; public bool TestMode { get; set; } = true; public bool EnableBetaFeatures { get; set; } = false; - public string ProfitTrailerPath { get; set; } public string ProfitTrailerLicense { get; set; } = ""; public string ProfitTrailerServerAPIToken { get; set; } public string ProfitTrailerMonitorURL { get; set; } = "http://localhost:8081/"; diff --git a/Core/Helper/SystemHelper.cs b/Core/Helper/SystemHelper.cs index dcb2f79..e3836ba 100644 --- a/Core/Helper/SystemHelper.cs +++ b/Core/Helper/SystemHelper.cs @@ -542,7 +542,7 @@ namespace Core.Helper } else { - result = "https://uk.tradingview.com/?symbol=" + exchange.ToUpper() + ":" + market.ToUpper(); + result = "https://uk.tradingview.com/chart/?symbol=" + exchange.ToUpper() + ":" + market.ToUpper(); } } else diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 19c986d..c585351 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -703,20 +703,11 @@ namespace Core.Main { try { - if (this.PTMagicConfiguration.GeneralSettings.Application.TestMode) this.Log.DoLogInfo("TESTMODE ENABLED - No files will be changed!"); - - // Check for PT Directory - DirectoryInfo ptRoot = new DirectoryInfo(this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath); - if (ptRoot.Exists) + if (this.PTMagicConfiguration.GeneralSettings.Application.TestMode) { - this.Log.DoLogInfo("Profit Trailer directory found"); - result = RunProfitTrailerSettingsAPIChecks(); - } - else - { - this.Log.DoLogError("Profit Trailer directory not found (" + this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + ")"); - result = false; + this.Log.DoLogInfo("TESTMODE ENABLED - No files will be changed!"); } + result = RunProfitTrailerSettingsAPIChecks(); // Check for CoinMarketCap API Key if (!String.IsNullOrEmpty(this.PTMagicConfiguration.GeneralSettings.Application.CoinMarketCapAPIKey)) @@ -1142,14 +1133,7 @@ namespace Core.Main } } - private void GetProfitTrailerPropertiesPaths(out string pairsPropertiesPath, out string dcaPropertiesPath, out string indicatorsPropertiesPath) - { - // Get current PT properties - pairsPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.PairsFileName; - dcaPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.DCAFileName; - indicatorsPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.IndicatorsFileName; - } - + // Get current PT properties private void LoadCurrentProfitTrailerProperties() { // Load current PT properties from API (Valid for PT 2.x and above) @@ -2143,9 +2127,6 @@ namespace Core.Main private void SaveProfitTrailerProperties() { // Get current PT properties - string pairsPropertiesPath, dcaPropertiesPath, indicatorsPropertiesPath; - GetProfitTrailerPropertiesPaths(out pairsPropertiesPath, out dcaPropertiesPath, out indicatorsPropertiesPath); - if (this.GlobalSettingWritten || this.SingleMarketSettingChanged) { // Save current PT properties to API (Valid for PT 2.x and above) diff --git a/Core/Main/PTMagicConfiguration.cs b/Core/Main/PTMagicConfiguration.cs index 7d29d14..3931664 100644 --- a/Core/Main/PTMagicConfiguration.cs +++ b/Core/Main/PTMagicConfiguration.cs @@ -47,11 +47,6 @@ namespace Core.Main AnalyzerSettingsWrapper asw = JsonConvert.DeserializeObject(File.ReadAllText(basePath + "settings.analyzer.json")); _analyzerSettings = asw.AnalyzerSettings; - if (!_generalSettings.Application.ProfitTrailerPath.EndsWith(Path.DirectorySeparatorChar)) - { - _generalSettings.Application.ProfitTrailerPath += Path.DirectorySeparatorChar; - } - if (!_generalSettings.Application.ProfitTrailerMonitorURL.EndsWith("/")) { _generalSettings.Application.ProfitTrailerMonitorURL += "/"; @@ -83,6 +78,28 @@ namespace Core.Main return result; } + public string GetProfitTrailerServerAPITokenMasked() + { + string result = ""; + + if (!this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Equals("")) + { + int tokenLength = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length; + if (tokenLength == 1) + { + result = "*"; + } + else + result = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(0, 1); + for (int i = 1; i < this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length; i++) + { + result += "*"; + } + } + + return result; + } + public GeneralSettings GeneralSettings { get diff --git a/Monitor/Pages/Login.cshtml.cs b/Monitor/Pages/Login.cshtml.cs index 6958d1a..44c35c5 100644 --- a/Monitor/Pages/Login.cshtml.cs +++ b/Monitor/Pages/Login.cshtml.cs @@ -30,7 +30,8 @@ namespace Monitor.Pages if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword)) { HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")); - + PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected = true; + PTMagicConfiguration.WriteGeneralSettings(); if (cbRememberMe != null) { if (cbRememberMe.Equals("on", StringComparison.InvariantCultureIgnoreCase)) diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml index 64c3783..bd8a46a 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml +++ b/Monitor/Pages/SettingsGeneral.cshtml @@ -68,12 +68,6 @@ -
- -
- @Model.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath -
-
@@ -92,7 +86,7 @@
- + @Model.PTMagicConfiguration.GetProfitTrailerServerAPITokenMasked()
@@ -139,14 +133,14 @@
- +
- +
@@ -169,9 +163,9 @@
- +
diff --git a/Monitor/Pages/SettingsGeneral.cshtml.cs b/Monitor/Pages/SettingsGeneral.cshtml.cs index 7cf9d5c..5a031e3 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml.cs +++ b/Monitor/Pages/SettingsGeneral.cshtml.cs @@ -71,7 +71,6 @@ namespace Monitor.Pages PTMagicConfiguration.GeneralSettings.Application.StartBalance = SystemHelper.TextToDouble(HttpContext.Request.Form["Application_StartBalance"], PTMagicConfiguration.GeneralSettings.Application.StartBalance, "en-US"); PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerDefaultSettingName = HttpContext.Request.Form["Application_ProfitTrailerDefaultSettingName"]; - PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken = HttpContext.Request.Form["Application_ProfitTrailerServerAPIToken"]; PTMagicConfiguration.GeneralSettings.Application.TimezoneOffset = HttpContext.Request.Form["Application_TimezoneOffset"]; PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency = HttpContext.Request.Form["Application_MainFiatCurrency"]; diff --git a/Monitor/Pages/SetupPassword.cshtml b/Monitor/Pages/SetupPassword.cshtml index 7c2f9d0..7561630 100644 --- a/Monitor/Pages/SetupPassword.cshtml +++ b/Monitor/Pages/SetupPassword.cshtml @@ -14,29 +14,30 @@

PT Magic

Setup your password.

-
-
-
- -
-
-
-
- + @if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "/settings.secure.json")) + { +
+
+ +
-
- - @if (!Model.ValidationMessage.Equals("")) { -
-
- @Model.ValidationMessage -
-
} +
+
+ +
+
+ +
+
+ +
+
+
- +
+
+ @Model.ValidationMessage +
+
-
diff --git a/Monitor/Pages/SetupPassword.cshtml.cs b/Monitor/Pages/SetupPassword.cshtml.cs index eb53c5f..8d83132 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"); + } } } diff --git a/Monitor/Pages/_Layout.cshtml b/Monitor/Pages/_Layout.cshtml index ccc4465..8096a29 100644 --- a/Monitor/Pages/_Layout.cshtml +++ b/Monitor/Pages/_Layout.cshtml @@ -107,7 +107,7 @@ } else {
  • - Settings + Settings
  • } diff --git a/Monitor/_Internal/BasePageModelSecure.cs b/Monitor/_Internal/BasePageModelSecure.cs index 080b8ef..d0a2917 100644 --- a/Monitor/_Internal/BasePageModelSecure.cs +++ b/Monitor/_Internal/BasePageModelSecure.cs @@ -1,4 +1,5 @@ -using System; +using System.Net; +using System; using Microsoft.AspNetCore.Http; using Core.Main; using Core.Helper; @@ -27,7 +28,8 @@ namespace Monitor._Internal // Security check if (!IsLoggedIn(this.HttpContext)) { - HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + _redirectUrl); + this.HttpContext.Response.Clear(); + this.HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + _redirectUrl); } } diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index 97e290c..94716b9 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -6,7 +6,7 @@ using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.5.6")] +[assembly: AssemblyVersion("2.5.7")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic diff --git a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json index e594c7b..eac6cf2 100644 --- a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json +++ b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json @@ -3,7 +3,6 @@ "Application": { "IsEnabled": true, // Enables the PTMagic bot (needs restart to take effect) "TestMode": false, // If TestMode is active, no properties files will be changed - "ProfitTrailerPath": "YOUR PROFIT TRAILER PATH", // Path to your Profit Trailer main directory (use double backslashes for windows like C:\\ProfitTrailer\\) "ProfitTrailerLicense": "YOUR PROFIT TRAILER LICENSE KEY", // Your Profit Trailer license key (needed to change your settings for PT 2.0 and above) "ProfitTrailerServerAPIToken": "", //Your Profit Trailer Server API Token "ProfitTrailerMonitorURL": "http://localhost:8081/", // The URL to your profit trailer monitor (needed to change your settings for PT 2.0 and above) diff --git a/_Development/DevSettings/settings.general.json b/_Development/DevSettings/settings.general.json index bb38a61..33b8405 100644 --- a/_Development/DevSettings/settings.general.json +++ b/_Development/DevSettings/settings.general.json @@ -3,7 +3,6 @@ "Application": { "IsEnabled": true, // Enables the PTMagic bot (needs restart to take effect) "TestMode": false, // If TestMode is active, no properties files will be changed - "ProfitTrailerPath": "YOUR PROFIT TRAILER PATH", // Path to your Profit Trailer main directory (use double backslashes for windows like C:\\ProfitTrailer\\) "ProfitTrailerLicense": "YOUR PROFIT TRAILER LICENSE KEY", // Your Profit Trailer license key (needed to change your settings for PT 2.0 and above) "ProfitTrailerServerAPIToken": "", //Your Profit Trailer Server API Token "ProfitTrailerMonitorURL": "http://localhost:8081/", // The URL to your profit trailer monitor (needed to change your settings for PT 2.0 and above)