@inherits LayoutComponentBase @using System.Security.Claims @using Microsoft.AspNetCore.Components.Authorization @using Syncfusion.Blazor.Navigations @using static Syncfusion.Blazor.Navigations.Orientation @using Syncfusion.Blazor.Buttons @inject NavigationManager NavigationManager @inject CustomAuthenticationStateProvider AuthenticationStateProvider
Icon

FA Krosno Manager

@if (IsAuthenticated) { Jesteś zalogowany jako @UserName Wyloguj } else { Zaloguj }
@if (UserName == "pkus") { }
@Body
@code { private bool IsAuthenticated { get; set; } private string UserName { get; set; } = string.Empty; protected override void OnInitialized() { ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser(); IsAuthenticated = currentUser.Identity?.IsAuthenticated == true; UserName = currentUser.Identity?.Name ?? "Nieznany użytkownik"; AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged; } private async void OnAuthenticationStateChanged(Task task) { var authState = await task; IsAuthenticated = authState.User.Identity?.IsAuthenticated ?? false; UserName = IsAuthenticated ? authState.User.Identity?.Name ?? "Nieznany użytkownik" : string.Empty; StateHasChanged(); } private void Logout() { NavigationManager.NavigateTo("/"); } }
An unhandled error has occurred. Reload 🗙