Files
mapo-core/MP.Land/Components/CmpTop.razor.cs
T
Samuele Locatelli 5ced0fec53 LAND:
- fix warning compilazione
- fix auth windows x login
2022-11-15 18:08:19 +01:00

80 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System;
using System.Threading.Tasks;
namespace MP.Land.Components
{
public partial class CmpTop
{
#region Public Methods
public void Dispose()
{
AppMessages.EA_PageUpdated -= OnPageUpdate;
GC.Collect();
}
public void OnPageUpdate()
{
PageName = AppMessages.PageName;
PageIcon = AppMessages.PageIcon;
InvokeAsync(() =>
{
StateHasChanged();
});
}
#endregion Public Methods
#region Protected Methods
protected override void OnInitialized()
{
AppMessages.EA_PageUpdated += OnPageUpdate;
}
protected override async Task OnInitializedAsync()
{
await forceReload();
}
#endregion Protected Methods
#region Private Fields
private string userName = "";
#endregion Private Fields
#region Private Properties
private string PageIcon { get; set; }
private string PageName { get; set; }
[CascadingParameter(Name = "ShowSearch")]
private bool ShowSearch { get; set; }
#endregion Private Properties
#region Private Methods
private async Task forceReload()
{
userName = "N.A.";
await Task.Delay(1); var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
}
#endregion Private Methods
}
}