first commit ish
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
@implements IDisposable
|
||||
@implements IDisposable
|
||||
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject AuthenticationStateProvider AuthStateProvider
|
||||
@inject EntKube.Web.Services.UserAccessService UserAccessService
|
||||
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
@@ -18,11 +20,14 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="tenants">
|
||||
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Tenants
|
||||
</NavLink>
|
||||
</div>
|
||||
@if (showTenantsLink)
|
||||
{
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="tenants">
|
||||
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Tenants
|
||||
</NavLink>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="portal">
|
||||
@@ -30,6 +35,22 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="portal/status">
|
||||
<span class="bi bi-activity-nav-menu" aria-hidden="true"></span> Status
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<AuthorizeView Roles="Admin">
|
||||
<Authorized>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="admin/backup">
|
||||
<span class="bi bi-arrow-repeat-nav-menu" aria-hidden="true"></span> Backup
|
||||
</NavLink>
|
||||
</div>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<div class="nav-item px-3">
|
||||
@@ -65,11 +86,22 @@
|
||||
|
||||
@code {
|
||||
private string? currentUrl;
|
||||
private bool showTenantsLink;
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
|
||||
NavigationManager.LocationChanged += OnLocationChanged;
|
||||
|
||||
AuthenticationState authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
System.Security.Claims.ClaimsPrincipal user = authState.User;
|
||||
|
||||
if (user.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
string? userId = user.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value;
|
||||
if (userId is not null)
|
||||
showTenantsLink = await UserAccessService.HasAnyAccessAsync(userId);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
||||
@@ -83,4 +115,3 @@
|
||||
NavigationManager.LocationChanged -= OnLocationChanged;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user