2018-05-22 10:11:50 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Core.Main;
|
|
|
|
|
using Core.Helper;
|
|
|
|
|
using Core.Main.DataObjects.PTMagicData;
|
|
|
|
|
using Core.MarketAnalyzer;
|
|
|
|
|
using Core.ProfitTrailer;
|
|
|
|
|
using Microsoft.Extensions.Primitives;
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
namespace Monitor._Internal
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
public class BasePageModelSecureAJAX : BasePageModel
|
|
|
|
|
{
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
base.PreInit();
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (String.IsNullOrEmpty(HttpContext.Session.GetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString())) && PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
bool redirectToLogin = true;
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (Request.Cookies.ContainsKey("PTMRememberMeKey"))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
string rememberMeKey = Request.Cookies["PTMRememberMeKey"];
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (!rememberMeKey.Equals(""))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
string encryptedPassword = EncryptionHelper.Decrypt(Request.Cookies["PTMRememberMeKey"]);
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
|
|
|
|
|
{
|
2019-02-04 01:17:38 +01:00
|
|
|
|
HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
|
2018-05-22 10:11:50 +02:00
|
|
|
|
redirectToLogin = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (redirectToLogin)
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "_get/ReturnToLogin");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|