Files
mapo-core/MP.SPEC/Components/CmpTop.razor
T
Samuele Locatelli a46dc9cb32 Bozza pagine
2022-07-21 14:21:14 +02:00

49 lines
1.1 KiB
Plaintext

@using MP.SPEC.Components
@using MP.SPEC.Data
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@inject AuthenticationStateProvider AuthenticationStateProvider
<div class="d-flex w-100 justify-content-between">
<div class="px-2">
<i class="fas fa-user-alt"></i> <b>@userName</b>
</div>
<div class="px-2 flex-grow-1">
</div>
<div class="px-2 text-end">
@if (ShowSearch)
{
<SearchMod></SearchMod>
}
</div>
</div>
@code {
[CascadingParameter(Name ="ShowSearch")]
protected bool ShowSearch { get; set; }
private string userName = "";
protected override async Task OnInitializedAsync()
{
await forceReload();
}
private async Task forceReload()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
}
}