Protect finance cockpit with login
This commit is contained in:
@@ -1,23 +1,53 @@
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@inject NavigationManager Navigation
|
||||
@inject TrafagSalesExporter.Services.IFinanceCockpitAccessService FinanceAccess
|
||||
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<LayoutView Layout="typeof(Layout.MainLayout)">
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Outlined">
|
||||
Zugriff verweigert. Bitte mit einem berechtigten Windows-/Domain-Benutzer anmelden.
|
||||
</MudAlert>
|
||||
</LayoutView>
|
||||
</NotAuthorized>
|
||||
<Authorizing>
|
||||
<LayoutView Layout="typeof(Layout.MainLayout)">
|
||||
<MudProgressCircular Indeterminate="true" />
|
||||
</LayoutView>
|
||||
</Authorizing>
|
||||
</AuthorizeRouteView>
|
||||
@if (RequiresFinanceUnlock() && FinanceAccess.IsEnabled && !FinanceAccess.IsUnlocked)
|
||||
{
|
||||
<LayoutView Layout="typeof(Layout.MainLayout)">
|
||||
<FinanceCockpitUnlockPanel />
|
||||
</LayoutView>
|
||||
}
|
||||
else
|
||||
{
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<LayoutView Layout="typeof(Layout.MainLayout)">
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Outlined">
|
||||
Zugriff verweigert. Bitte mit einem berechtigten Windows-/Domain-Benutzer anmelden.
|
||||
</MudAlert>
|
||||
</LayoutView>
|
||||
</NotAuthorized>
|
||||
<Authorizing>
|
||||
<LayoutView Layout="typeof(Layout.MainLayout)">
|
||||
<MudProgressCircular Indeterminate="true" />
|
||||
</LayoutView>
|
||||
</Authorizing>
|
||||
</AuthorizeRouteView>
|
||||
}
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
|
||||
@code {
|
||||
private bool RequiresFinanceUnlock()
|
||||
{
|
||||
var path = Navigation.ToBaseRelativePath(Navigation.Uri)
|
||||
.Split('?', '#')[0]
|
||||
.Trim('/')
|
||||
.ToLowerInvariant();
|
||||
|
||||
return path is "" or
|
||||
"management-cockpit" or
|
||||
"finance-cockpit/vergleich" or
|
||||
"standorte" or
|
||||
"transformations" or
|
||||
"settings" or
|
||||
"logs" or
|
||||
"source-viewer";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user