@page "/" @using Microsoft.AspNetCore.Authorization @using System.Security.Claims @attribute [Authorize] @inject AuthenticationStateProvider AuthenticationStateProvider Home - SmartDB

Benvenuto in SmartDB

Applicazione di gestione avanzata

Utente: @currentUserEmail

@currentUserName

@if (isAdmin) { }
Dashboard

Benvenuto nell'applicazione SmartDB. Qui troverai tutti gli strumenti necessari per gestire i tuoi dati.

@code { private string currentUserEmail = string.Empty; private string currentUserName = string.Empty; private bool isAdmin = false; protected override async Task OnInitializedAsync() { var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); var user = authState.User; if (user.Identity?.IsAuthenticated ?? false) { currentUserEmail = user.FindFirst(ClaimTypes.Email)?.Value ?? user.Identity.Name ?? "Utente"; currentUserName = $"{user.FindFirst(ClaimTypes.GivenName)?.Value} {user.FindFirst(ClaimTypes.Surname)?.Value}".Trim(); isAdmin = user.IsInRole("Admin"); } } }