using System.Security.Claims; using Blazorise.Extensions; using Microsoft.AspNetCore.Components.Authorization; namespace NetinaShop.AdminPanel.PWA.Services; public class CustomAuthenticationStateProvider : AuthenticationStateProvider { private readonly IUserUtility _userUtility; public CustomAuthenticationStateProvider(IUserUtility userUtility) { _userUtility = userUtility; } public override async Task GetAuthenticationStateAsync() { var token = await _userUtility.GetBearerTokenAsync(); if (token.IsNullOrEmpty()) { return new AuthenticationState(new()); } var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "mrfibuli"), }, "Custom Authentication"); var user = new ClaimsPrincipal(identity); return new AuthenticationState(user); } }