48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
namespace MagMan.UI.Components
|
|
{
|
|
public partial class LoginDisplay
|
|
{
|
|
#region Private Fields
|
|
|
|
private string userName = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await forceReload();
|
|
}
|
|
|
|
protected string StringLim(string original, int maxLen)
|
|
{
|
|
return original.Length <= maxLen ? original : $"{original.Substring(0, maxLen - 3)}...";
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#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 = "Non Autenticato";
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |