fix gestione sessione con local storage
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Blazored.SessionStorage;
|
||||
using Blazored.LocalStorage;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Data.DTO;
|
||||
@@ -19,7 +20,7 @@ namespace MP.INVE.Components
|
||||
|
||||
public async Task LogOut()
|
||||
{
|
||||
await sessionStorage.ClearAsync();
|
||||
await localStorage.ClearAsync();
|
||||
// rimando a pagina login
|
||||
NavManager.NavigateTo("OperatoreLogin", true);
|
||||
}
|
||||
@@ -38,10 +39,14 @@ namespace MP.INVE.Components
|
||||
protected async Task getId()
|
||||
{
|
||||
OperatoreDTO answ = new OperatoreDTO();
|
||||
answ = await sessionStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
||||
answ = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
||||
if (answ != null)
|
||||
{
|
||||
userName = $"{answ.Cognome} {answ.Cognome} ({answ.MatrOpr})";
|
||||
userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})";
|
||||
if (NavManager.Uri.Contains("OperatoreLogin"))
|
||||
{
|
||||
NavManager.NavigateTo("Starter", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -70,9 +75,10 @@ namespace MP.INVE.Components
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private ISessionStorageService sessionStorage { get; set; } = null!;
|
||||
[Inject]
|
||||
private ILocalStorageService localStorage { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.INVE</RootNamespace>
|
||||
<Version>6.16.2211.1612</Version>
|
||||
<Version>6.16.2211.1615</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -27,6 +27,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.9" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
|
||||
@@ -1,34 +1,60 @@
|
||||
@page "/OperatoreLogin"
|
||||
|
||||
<div class="card loginOperatore">
|
||||
<div class="card-header text-center">
|
||||
<h1>OperatoreLogin</h1>
|
||||
</div>
|
||||
<div class="card-body ">
|
||||
<label class="form-label">Selezionare operatore</label>
|
||||
<div class="mb-3">
|
||||
<div class="row">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-10">
|
||||
|
||||
<div>
|
||||
<select class="form-select" aria-label="Default select example" @bind="@idOperatore">
|
||||
@if (elencoOperatori != null)
|
||||
{
|
||||
@foreach (var item in elencoOperatori)
|
||||
{
|
||||
<option value="@item.MatrOpr">@item.Cognome @item.Nome (@item.MatrOpr)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">Inserire auth key</label>
|
||||
<input class="form-control" type="password" @bind="@authKey" />
|
||||
<div class="align-content-center p-3">
|
||||
<div class="card loginOperatore">
|
||||
<div class="card-header text-center">
|
||||
<h1>login Operatore</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-10">
|
||||
<label class="form-label">Selezionare operatore</label>
|
||||
<div class="mb-3">
|
||||
|
||||
<div>
|
||||
<select class="form-select" aria-label="Default select example" @bind="@idOperatore">
|
||||
@if (elencoOperatori != null)
|
||||
{
|
||||
@foreach (var item in elencoOperatori)
|
||||
{
|
||||
<option value="@item.MatrOpr">@item.Cognome @item.Nome (@item.MatrOpr)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-10">
|
||||
<label class="form-label">Inserire auth key</label>
|
||||
<input class="form-control mb-3" type="password" @bind="@authKey" />
|
||||
</div>
|
||||
<div class="col-1"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-10">
|
||||
<button class="btn btn-primary" @onclick="login">LOGIN</button>
|
||||
</div>
|
||||
<div class="col-1"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-primary" @onclick="login">SUBMIT</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-1"></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using MP.INVE.Components;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Blazored.SessionStorage;
|
||||
using MP.Data.DTO;
|
||||
using Blazored.LocalStorage;
|
||||
|
||||
namespace MP.INVE.Pages
|
||||
{
|
||||
@@ -29,6 +30,8 @@ namespace MP.INVE.Pages
|
||||
private NavigationManager NavManager { get; set; } = null!;
|
||||
[Inject]
|
||||
private ISessionStorageService sessionStorage { get; set; } = null!;
|
||||
[Inject]
|
||||
private ILocalStorageService localStorage { get; set; } = null!;
|
||||
|
||||
private int idOperatore { get; set; } = 0;
|
||||
private string authKey { get; set; } = "";
|
||||
@@ -48,22 +51,23 @@ namespace MP.INVE.Pages
|
||||
|
||||
AnagOperatoriModel? currOpr = elencoOperatori.SingleOrDefault();
|
||||
|
||||
|
||||
if (currOpr != null)
|
||||
{
|
||||
string hash = MIDataservice.EncriptData(currOpr.authKey);
|
||||
OperatoreDTO sessionOpr = new OperatoreDTO
|
||||
{
|
||||
MatrOpr = currOpr.MatrOpr,
|
||||
Nome = currOpr.Nome,
|
||||
Cognome = currOpr.Cognome,
|
||||
hashAuthKey = currOpr.authKey
|
||||
hashAuthKey = hash
|
||||
};
|
||||
|
||||
|
||||
if (elencoOperatori.Count == 1)
|
||||
{
|
||||
NavManager.NavigateTo("/Starter", true);
|
||||
sessionStorage.SetItemAsync("MatrOpr", sessionOpr);
|
||||
//sessionStorage.SetItemAsync("AuthKey", authKey);
|
||||
localStorage.SetItemAsync("MatrOpr", sessionOpr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@ using MP.INVE.Shared;
|
||||
using MP.INVE.Components;
|
||||
using Blazored.SessionStorage;
|
||||
using MP.Data.DTO;
|
||||
using MP.INVE.Data;
|
||||
using Blazored.LocalStorage;
|
||||
|
||||
namespace MP.INVE.Pages
|
||||
{
|
||||
@@ -26,6 +28,11 @@ namespace MP.INVE.Pages
|
||||
|
||||
[Inject]
|
||||
private ISessionStorageService sessionStorage { get; set; } = null!;
|
||||
[Inject]
|
||||
private ILocalStorageService localStorage { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private MiDataService MIDataservice { get; set; } = null!;
|
||||
|
||||
private int idOperatore { get; set; } = 0;
|
||||
private string authKey { get; set; } = "";
|
||||
@@ -48,12 +55,15 @@ namespace MP.INVE.Pages
|
||||
|
||||
protected async Task getId()
|
||||
{
|
||||
OperatoreDTO answ = new OperatoreDTO();
|
||||
answ = await sessionStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
||||
if (answ != null)
|
||||
OperatoreDTO sess = new OperatoreDTO();
|
||||
OperatoreDTO local = new OperatoreDTO();
|
||||
sess = await sessionStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
||||
local = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
||||
if ((local != null))
|
||||
{
|
||||
idOperatore = answ.MatrOpr;
|
||||
authKey = answ.hashAuthKey;
|
||||
string auth = local.hashAuthKey;
|
||||
idOperatore = local.MatrOpr;
|
||||
authKey = auth;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.AspNetCore.Authentication.Negotiate;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -41,7 +42,10 @@ builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<MiDataService>();
|
||||
builder.Services.AddScoped<MessageService>();
|
||||
// aggiungere servizio da usare come DI x gestione session, aggiungere anche local storage
|
||||
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddSingleton<IOApiService>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOINVE </i>
|
||||
<h4>Versione: 6.16.2211.1612</h4>
|
||||
<h4>Versione: 6.16.2211.1615</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2211.1612
|
||||
6.16.2211.1615
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2211.1612</version>
|
||||
<version>6.16.2211.1615</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user