68 lines
2.2 KiB
Plaintext
68 lines
2.2 KiB
Plaintext
@page "/"
|
|
@using Microsoft.AspNetCore.Authorization
|
|
@using System.Security.Claims
|
|
@attribute [Authorize]
|
|
|
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
|
|
|
<PageTitle>Home - SmartDB</PageTitle>
|
|
|
|
<div class="container-fluid mt-4">
|
|
<div class="row mb-4">
|
|
<div class="col-md-8">
|
|
<h1>Benvenuto in SmartDB</h1>
|
|
<p class="lead">Applicazione di gestione avanzata</p>
|
|
</div>
|
|
<div class="col-md-4 text-end">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<p class="card-text">Utente: <strong>@currentUserEmail</strong></p>
|
|
<p class="card-text text-muted">@currentUserName</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if (isAdmin)
|
|
{
|
|
<div class="alert alert-info" role="alert">
|
|
<h4 class="alert-heading">Pannello Amministratore</h4>
|
|
<p>Hai accesso alle funzioni di amministrazione.</p>
|
|
<hr />
|
|
<a href="/admin/users" class="btn btn-sm btn-primary">Gestisci Utenti</a>
|
|
</div>
|
|
}
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5>Dashboard</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p>Benvenuto nell'applicazione SmartDB. Qui troverai tutti gli strumenti necessari per gestire i tuoi dati.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@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");
|
|
}
|
|
}
|
|
}
|