diff --git a/MP.INVE/Components/CmpTop.razor b/MP.INVE/Components/CmpTop.razor
index c2578ed2..37177405 100644
--- a/MP.INVE/Components/CmpTop.razor
+++ b/MP.INVE/Components/CmpTop.razor
@@ -6,20 +6,24 @@
@inject AuthenticationStateProvider AuthenticationStateProvider
-
+
@userName
+ @if (userName != "0")
+ {
+
+ }
- @*
-
@TipoSearch
+ @*
+ @TipoSearch
- @if (ShowSearch)
- {
-
- }
+ @if (ShowSearch)
+ {
+
+ }
*@
diff --git a/MP.INVE/Components/CmpTop.razor.cs b/MP.INVE/Components/CmpTop.razor.cs
index 0fc621ce..8c704ed0 100644
--- a/MP.INVE/Components/CmpTop.razor.cs
+++ b/MP.INVE/Components/CmpTop.razor.cs
@@ -1,3 +1,4 @@
+using Blazored.SessionStorage;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.JSInterop;
@@ -17,6 +18,13 @@ namespace MP.INVE.Components
NavManager.NavigateTo(NavManager.Uri, true);
}
+ public async Task LogOut()
+ {
+ await sessionStorage.ClearAsync();
+ // rimando a pagina login
+ NavManager.NavigateTo("OperatoreLogin", true);
+ }
+
#endregion Public Methods
#region Protected Properties
@@ -24,6 +32,9 @@ namespace MP.INVE.Components
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
+ [Inject]
+ private ISessionStorageService sessionStorage { get; set; } = null!;
+
#endregion Protected Properties
#region Protected Methods
@@ -32,6 +43,12 @@ namespace MP.INVE.Components
{
await forceReload();
}
+ protected async Task getId()
+ {
+ int answ = 0;
+ answ = await sessionStorage.GetItemAsync
("MatrOpr");
+ userName = answ.ToString();
+ }
#endregion Protected Methods
@@ -53,17 +70,8 @@ namespace MP.INVE.Components
#region Private Methods
private async Task forceReload()
- {
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
- var user = authState.User;
- if (user.Identity != null && user.Identity.IsAuthenticated)
- {
- userName = $"{user.Identity.Name}";
- }
- else
- {
- userName = "N.A.";
- }
+ {
+ await getId();
}
private async void MService_EA_ShowSearch()