69 lines
2.6 KiB
Plaintext
69 lines
2.6 KiB
Plaintext
@using HopFrame.Core.Config
|
|
@using HopFrame.Core.Services
|
|
@using HopFrame.Web.Models
|
|
@using Microsoft.Extensions.DependencyInjection
|
|
@inherits LayoutComponentBase
|
|
|
|
<link rel="stylesheet" type='text/css' href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css" />
|
|
<link rel="stylesheet" href="@Assets["_content/HopFrame.Web/hopframe.css"]"/>
|
|
<link rel="stylesheet" href="@Assets["_content/HopFrame.Web/HopFrame.Web.bundle.scp.css"]"/>
|
|
<link rel="stylesheet" href="@Assets["_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css"]"/>
|
|
<link rel="stylesheet" href="@Assets["_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.bundle.scp.css"]">
|
|
|
|
<FluentDesignTheme Mode="DesignThemeModes.Dark" />
|
|
|
|
<FluentLayout Class="hopframe-outer">
|
|
<HopFrameNavigation />
|
|
<FluentStack Orientation="Orientation.Horizontal" Width="100%" Class="hopframe-main">
|
|
<HopFrameSideMenu />
|
|
<FluentBodyContent>
|
|
<div class="hopframe-content">
|
|
@Body
|
|
</div>
|
|
</FluentBodyContent>
|
|
</FluentStack>
|
|
<FluentFooter>
|
|
<a href="https://git.leon-hoppe.de/leon.hoppe/hopframe" target="_blank">Documentation and source code</a>
|
|
<FluentSpacer/>
|
|
<a href="https://git.leon-hoppe.de/leon.hoppe/" target="_blank" style="margin-right: 0.25rem; text-decoration: none">
|
|
<i class="devicon-gitlab-plain"></i>
|
|
</a>
|
|
<a href="https://github.com/leonhoppe" target="_blank" style="text-decoration: none">
|
|
<i class="devicon-github-original"></i>
|
|
</a>
|
|
</FluentFooter>
|
|
</FluentLayout>
|
|
|
|
@inject IHopFrameAuthHandler Handler
|
|
@inject HopFrameConfig Config
|
|
@inject NavigationManager Navigator
|
|
|
|
@code {
|
|
|
|
internal static readonly List<CustomView> CustomViews = new();
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
var authorized = await Handler.IsAuthenticatedAsync(Config.BasePolicy);
|
|
|
|
var currentUri = "/" + Navigator.ToBaseRelativePath(Navigator.Uri);
|
|
|
|
if (authorized) {
|
|
foreach (var view in CustomViews.Where(view => !string.IsNullOrWhiteSpace(view.Policy))) {
|
|
switch (view.LinkMatch) {
|
|
case NavLinkMatch.All when currentUri != view.Url:
|
|
case NavLinkMatch.Prefix when !currentUri.StartsWith(view.Url):
|
|
continue;
|
|
}
|
|
|
|
authorized = await Handler.IsAuthenticatedAsync(view.Policy);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!authorized) {
|
|
Navigator.NavigateTo((Config.LoginPageRewrite ?? "/login") + "?redirect=" + currentUri, true);
|
|
}
|
|
}
|
|
|
|
}
|