89 lines
2.8 KiB
Plaintext
89 lines
2.8 KiB
Plaintext
@using System.Net
|
|
@using System.Reflection
|
|
@using LucideBlazor
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@using Microsoft.Extensions.Options
|
|
@using Moonlight.Frontend.Configuration
|
|
@using Moonlight.Frontend.UI.Shared
|
|
@using Moonlight.Frontend.UI.Shared.Components
|
|
@using ShadcnBlazor.Emptys
|
|
@using Moonlight.Frontend.UI.Shared.Components.Auth
|
|
@using Moonlight.Frontend.UI.Shared.Partials
|
|
|
|
@inject NavigationManager Navigation
|
|
@inject IOptions<NavigationAssemblyOptions> NavigationOptions
|
|
|
|
<ErrorBoundary>
|
|
<ChildContent>
|
|
<AuthorizeView>
|
|
<ChildContent>
|
|
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="Assemblies" NotFoundPage="typeof(NotFound)">
|
|
<Found Context="routeData">
|
|
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
|
|
<NotAuthorized Context="authRouteViewContext">
|
|
<AccessDenied/>
|
|
</NotAuthorized>
|
|
</AuthorizeRouteView>
|
|
</Found>
|
|
</Router>
|
|
</ChildContent>
|
|
<Authorizing>
|
|
<Authenticating/>
|
|
</Authorizing>
|
|
<NotAuthorized>
|
|
@if (context.User.Identity?.IsAuthenticated ?? false)
|
|
{
|
|
<AccessDenied/>
|
|
}
|
|
else
|
|
{
|
|
var uri = new Uri(Navigation.Uri);
|
|
|
|
if (uri.LocalPath.StartsWith("/setup"))
|
|
{
|
|
<Setup />
|
|
}
|
|
else
|
|
{
|
|
<Authentication/>
|
|
}
|
|
}
|
|
</NotAuthorized>
|
|
</AuthorizeView>
|
|
</ChildContent>
|
|
<ErrorContent>
|
|
@if (context is HttpRequestException { StatusCode: HttpStatusCode.Unauthorized })
|
|
{
|
|
<Authentication/>
|
|
}
|
|
else
|
|
{
|
|
<div class="m-10">
|
|
<Empty>
|
|
<EmptyHeader>
|
|
<EmptyMedia Variant="EmptyMediaVariant.Icon">
|
|
<OctagonAlertIcon ClassName="text-red-500/80"/>
|
|
</EmptyMedia>
|
|
<EmptyTitle>
|
|
Critical Application Error
|
|
</EmptyTitle>
|
|
<EmptyDescription>
|
|
@context.ToString()
|
|
</EmptyDescription>
|
|
</EmptyHeader>
|
|
</Empty>
|
|
</div>
|
|
}
|
|
</ErrorContent>
|
|
</ErrorBoundary>
|
|
|
|
@code
|
|
{
|
|
private Assembly[] Assemblies;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Assemblies = NavigationOptions.Value.Assemblies.ToArray();
|
|
}
|
|
}
|