aggiunta gestione login con guid dispositivo

This commit is contained in:
zaccaria.majid
2023-12-13 18:18:45 +01:00
parent db9d67e841
commit ec94724c79
10 changed files with 81 additions and 47 deletions
+33 -8
View File
@@ -251,8 +251,9 @@ namespace MP.Data.Services
public async Task<bool> DoLogIn(string decodValue, bool saveOpr)
{
bool answ = false;
expDays = SMService.GetConfInt("cookieDayExpire");
var expDT = DateTime.Now.AddDays(expDays);
//expDays = SMService.GetConfInt("cookieDayExpire");
//var expDT = DateTime.Now.AddDays(expDays);
var devGuid = await GetCurrDevGuidLSAsync();
// decifro i valori..
var decrVal = DecryptData(decodValue);
var opData = JsonConvert.DeserializeObject<userTknDTO>(decrVal);
@@ -264,17 +265,17 @@ namespace MP.Data.Services
userTknDTO newUserTkn = new userTknDTO()
{
currOpr = rigaOpr,
expTime = expDT
DevGuid = devGuid
};
var jsonTkn = JsonConvert.SerializeObject(newUserTkn);
string hash = TDService.EncryptData(jsonTkn);
RigaOper = rigaOpr;
await SetLastMatrOprAsync(rigaOpr.MatrOpr);
await SetCurrOperDtoAsync(hash);
await SetCurrOperDtoLSAsync(hash);
if (saveOpr)
{
await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash);
await TDService.OperatoreSetRedis(rigaOpr.MatrOpr, hash, devGuid);
}
answ = true;
}
@@ -287,17 +288,30 @@ namespace MP.Data.Services
return SteamCrypto.EncryptString(rawData, Constants.passPhrase);
}
/// <summary>
/// Restituisce il record device GUID da localstorage
/// </summary>
/// <returns></returns>
public async Task<Guid> GetCurrDevGuidLSAsync()
{
Guid answ = new Guid();
var result = await localStorage.GetItemAsync<string>("devGuid");
if (result != null)
{
answ = Guid.Parse(result);
}
return answ;
}
/// <summary>
/// Restituisce il record OperatoreDTO da localstorage
/// </summary>
/// <returns></returns>
public async Task<string> GetCurrOperDtoAsync()
public async Task<string> GetCurrOperDtoLSAsync()
{
string answ = "";
var result = await localStorage.GetItemAsync<string>("currTkn");
if (result != null)
{
//var data = JsonConvert.DeserializeObject<userTknDTO>(result);
answ = result;
}
return answ;
@@ -426,13 +440,24 @@ namespace MP.Data.Services
/// scrive il record OperatoreDTO nel localstorage
/// </summary>
/// <returns></returns>
public async Task<bool> SetCurrOperDtoAsync(string currTkn)
public async Task<bool> SetCurrOperDtoLSAsync(string currTkn)
{
bool answ = false;
await localStorage.SetItemAsync("currTkn", currTkn);
answ = true;
return answ;
}
/// <summary>
/// scrive il record Device GUID nel localstorage
/// </summary>
/// <returns></returns>
public async Task<bool> SetCurrDevGuidLSAsync(Guid currDevGuid)
{
bool answ = false;
await localStorage.SetItemAsync("devGuid", currDevGuid.ToString());
answ = true;
return answ;
}
/// <summary>
/// Scrive il valore di IPV4 del device nel localstoragee