diff options
| -rw-r--r-- | App.razor | 30 | ||||
| -rw-r--r-- | Pages/Component/RedirectLogin.razor | 6 | ||||
| -rw-r--r-- | Pages/ViewMedia.razor | 1 | ||||
| -rw-r--r-- | _Imports.razor | 2 |
4 files changed, 28 insertions, 11 deletions
@@ -1,11 +1,19 @@ -<Router AppAssembly="@typeof(App).Assembly"> - <Found Context="routeData"> - <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> - </Found> - <NotFound> - <PageTitle>Not found</PageTitle> - <LayoutView Layout="@typeof(MainLayout)"> - <p role="alert">Sorry, there's nothing at this address.</p> - </LayoutView> - </NotFound> -</Router> +<CascadingAuthenticationState> + <Router AppAssembly="@typeof(App).Assembly"> + <Found Context="routeData"> + <AuthorizeRouteView + RouteData="@routeData" + DefaultLayout="@typeof(MainLayout)"> + <NotAuthorized> + <RedirectLogin/> + </NotAuthorized> + </AuthorizeRouteView> + </Found> + <NotFound> + <PageTitle>Not found</PageTitle> + <LayoutView Layout="@typeof(MainLayout)"> + <p role="alert">Sorry, there's nothing at this address.</p> + </LayoutView> + </NotFound> + </Router> +</CascadingAuthenticationState> diff --git a/Pages/Component/RedirectLogin.razor b/Pages/Component/RedirectLogin.razor new file mode 100644 index 0000000..290a7ac --- /dev/null +++ b/Pages/Component/RedirectLogin.razor @@ -0,0 +1,6 @@ +@inject NavigationManager navigationManager + +@code { + protected override void OnInitialized() => + navigationManager.NavigateTo("/Login", true); +}
\ No newline at end of file diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor index 7823c75..444fbc5 100644 --- a/Pages/ViewMedia.razor +++ b/Pages/ViewMedia.razor @@ -4,6 +4,7 @@ @inject IDbContextFactory<HBContext> dbFactory @inject ITagService tagService @inject IMediaService mediaService +@attribute [Authorize] <PageTitle>@title</PageTitle> diff --git a/_Imports.razor b/_Imports.razor index d20a491..4c5566b 100644 --- a/_Imports.razor +++ b/_Imports.razor @@ -1,6 +1,8 @@ @using HyperBooru @using HyperBooru.Pages.Component @using HyperBooru.Services +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using Microsoft.EntityFrameworkCore |
