forse fix logout per ogni interazione

This commit is contained in:
zaccaria.majid
2023-12-11 15:35:21 +01:00
parent 39a202ea4a
commit da62b70acc
11 changed files with 121 additions and 46 deletions
+7 -5
View File
@@ -62,11 +62,13 @@ namespace MP_TAB_SERV.Components
await Task.Delay(1);
var rawVers = typeof(Program).Assembly.GetName().Version;
version = rawVers != null ? rawVers : new Version("0.0.0.0");
dtTimerScadenzaLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
if (dtTimerScadenzaLogin > 0)
{
StartTimer();
}
//dtTimerScadenzaLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
//dtTimerScadenzaLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
//if (dtTimerScadenzaLogin > 0)
//{
// //StartTimer();
//}
}
//protected override void OnInitialized()
+17 -28
View File
@@ -61,36 +61,18 @@ namespace MP_TAB_SERV.Components
#region Protected Methods
protected async Task DoLogIn(string decodValue)
protected async Task RefreshLogIn(string decodValue)
{
// decifro i valori..
var decrVal = MsgServ.DecryptData(decodValue);
var opData = JsonConvert.DeserializeObject<userTknDTO>(decrVal);
if (opData != null)
bool done = await MsgServ.DoLogIn(decodValue);
if (done)
{
var rigaOpr = await TDService.OperatoreSearch(opData.currOpr.MatrOpr, opData.currOpr.authKey);
if (rigaOpr != null)
if (!string.IsNullOrEmpty(LastOpenedPage) && !string.IsNullOrEmpty(CurrMacc))
{
userTknDTO newUserTkn = new userTknDTO()
{
currOpr = rigaOpr,
expTime = expDT
};
var jsonTkn = JsonConvert.SerializeObject(newUserTkn);
string hash = TDService.EncryptData(jsonTkn);
MsgServ.RigaOper = rigaOpr;
await MsgServ.SetLastMatrOprAsync(rigaOpr.MatrOpr);
await MsgServ.SetCurrOperDtoAsync(hash);
await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash);
if (LastOpenedPage != "" && CurrMacc != "")
{
NavMan.NavigateTo(LastOpenedPage);
}
else
{
NavMan.NavigateTo("status-map");
}
NavMan.NavigateTo(LastOpenedPage);
}
else
{
NavMan.NavigateTo("status-map");
}
}
}
@@ -148,9 +130,16 @@ namespace MP_TAB_SERV.Components
var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS);
// verifico se non avessi dati operatore
//var diffOfTime = DateTime.Now - MsgServ.dtLastAction;
//if (diffOfTime.Minutes >= 1)
//{
// NavMan.NavigateTo("logout");
//}
//else
if (MsgServ.RigaOper == null)
{
await DoLogIn(decodedUrl);
await RefreshLogIn(decodedUrl);
}
CurrOprTknRedis = await TDService.OperatoreGetRedis(MatrOpr);
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2312.717</Version>
<Version>6.16.2312.1115</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB_SERV</RootNamespace>
</PropertyGroup>
+1 -1
View File
@@ -58,7 +58,7 @@
<div class="d-flex justify-content-between my-2">
<div class="pe-2 col-6">
<button class="btn btn-sm btn-primary w-100" @onclick="()=>DoLogIn()">Log In</button>
<button class="btn btn-sm btn-primary w-100" @onclick="()=>FirstLogIn()">Log In</button>
</div>
<div class="ps-2 col-6">
<button class="btn btn-sm btn-warning w-100">Cancel</button>
+3 -3
View File
@@ -36,7 +36,7 @@ namespace MP_TAB_SERV.Pages
if (_authKey != value)
{
_authKey = value;
DoLogIn().ConfigureAwait(false);
FirstLogIn().ConfigureAwait(false);
}
}
}
@@ -87,7 +87,7 @@ namespace MP_TAB_SERV.Pages
{
return SMServ.Traduci($"EN_{lemma}".ToUpper());
}
protected async Task DoLogIn()
protected async Task FirstLogIn()
{
rigaOpr = await TDService.OperatoreSearch(matrOpr, authKey);
if (rigaOpr == null)
@@ -154,7 +154,7 @@ namespace MP_TAB_SERV.Pages
authKey = Uri_authKey;
}
}
await DoLogIn();
await FirstLogIn();
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2312.717</h4>
<h4>Versione: 6.16.2312.1115</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2312.717
6.16.2312.1115
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2312.717</version>
<version>6.16.2312.1115</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+39 -1
View File
@@ -72,7 +72,43 @@ namespace MP_TAB_SERV.Shared
protected async Task handleBodyClick()
{
await Task.Delay(1);
MsgServ.dtLastAction = DateTime.Now;
await checkDtDiff2Logout();
}
private int MatrOpr
{
get => MsgServ.MatrOpr;
}
protected int typeScadLogin { get; set; } = 0;
protected int dtScadLogin { get; set; } = 0;
protected async Task checkDtDiff2Logout()
{
var diffOfTime = DateTime.Now - MsgServ.dtLastAction;
switch (typeScadLogin)
{
case 0:
if (diffOfTime.Minutes >= dtScadLogin)
{
NavMan.NavigateTo("logout");
}
break;
case 1:
if (diffOfTime.Minutes >= dtScadLogin)
{
var userTkn = await TDataService.OperatoreGetRedis(MatrOpr);
if (!string.IsNullOrEmpty(userTkn))
{
await MsgServ.DoLogIn(userTkn);
MsgServ.dtLastAction = DateTime.Now;
}
else
{
NavMan.NavigateTo("logout");
}
}
break;
}
}
/// <summary>
@@ -81,6 +117,8 @@ namespace MP_TAB_SERV.Shared
/// <returns></returns>
protected override async Task OnInitializedAsync()
{
typeScadLogin = MStor.GetConfInt("TAB_TypeScadLogin");
dtScadLogin = MStor.GetConfInt("TAB_dtTimerScadLogin");
NavMan.LocationChanged += HandleLocationChanged;
// verifica preliminare setup mdati
if (!MStor.MenuOk)
+47 -1
View File
@@ -26,13 +26,15 @@ namespace MP.Data.Services
#region Public Constructors
public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore)
public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore, TabDataService tdService, SharedMemService smServ)
{
_configuration = configuration;
// gestione sessioni in browser
localStorage = genLocalStorage;
sessionStore = sessStore;
TDService = tdService;
SMService = smServ;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
@@ -436,6 +438,48 @@ namespace MP.Data.Services
return answ;
}
protected int expDays { get; set; } = 0;
public async Task<bool> DoLogIn(string decodValue)
{
bool answ = false;
expDays = SMService.GetConfInt("cookieDayExpire");
var expDT = DateTime.Now.AddDays(expDays);
// decifro i valori..
var decrVal = DecryptData(decodValue);
var opData = JsonConvert.DeserializeObject<userTknDTO>(decrVal);
if (opData != null)
{
var rigaOpr = await TDService.OperatoreSearch(opData.currOpr.MatrOpr, opData.currOpr.authKey);
if (rigaOpr != null)
{
userTknDTO newUserTkn = new userTknDTO()
{
currOpr = rigaOpr,
expTime = expDT
};
var jsonTkn = JsonConvert.SerializeObject(newUserTkn);
string hash = TDService.EncryptData(jsonTkn);
RigaOper = rigaOpr;
await SetLastMatrOprAsync(rigaOpr.MatrOpr);
await SetCurrOperDtoAsync(hash);
await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash);
answ = true;
//if (LastOpenedPage != "" && CurrMacc != "")
//{
// NavMan.NavigateTo(LastOpenedPage);
//}
//else
//{
// NavMan.NavigateTo("status-map");
//}
}
}
return answ;
}
/// <summary>
/// Salva matrOpr nel localstorage
/// </summary>
@@ -534,6 +578,8 @@ namespace MP.Data.Services
#region Protected Properties
protected ILocalStorageService localStorage { get; set; } = null!;
protected TabDataService TDService { get; set; } = null!;
protected SharedMemService SMService { get; set; } = null!;
protected ISessionStorageService sessionStore { get; set; } = null!;
+3 -3
View File
@@ -3001,7 +3001,7 @@ namespace MP.Data.Services
#region Protected Fields
protected double expDays = 0.0035;
protected int expMinutes = 1;
/// <summary>
/// Oggetto per connessione a REDIS
@@ -3022,7 +3022,7 @@ namespace MP.Data.Services
/// </summary>
protected TimeSpan ConfigCache
{
get => TimeSpan.FromDays(expDays);
get => TimeSpan.FromMinutes(expMinutes);
}
#endregion Protected Properties
@@ -3031,7 +3031,7 @@ namespace MP.Data.Services
protected void setExpDays()
{
ConfigGetVal("cookieDayExpire", ref expDays);
ConfigGetVal("cookieDayExpire", ref expMinutes);
}
#endregion Protected Methods