61 lines
1.6 KiB
C#
61 lines
1.6 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 MagMan.Core.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
namespace MagMan.UI.Components
|
|
{
|
|
public partial class LoginDisplay
|
|
{
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#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 Properties
|
|
|
|
private string userName
|
|
{
|
|
get => AppMService.UserName;
|
|
set => AppMService.UserName = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#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
|
|
}
|
|
} |