- Routes: wrap with CascadingAuthenticationState + AuthorizeRouteView - RedirectToLogin: component that redirects unauthenticated users to /login - HeimdallAuthStateProvider: NotifyLogin/NotifyLogout methods - Login/Register/MainLayout: use AuthStateProvider.NotifyLogin/Logout instead of direct AuthState mutation (triggers Blazor auth cascade) - _Imports: add Microsoft.AspNetCore.Components.Authorization
13 lines
527 B
Plaintext
13 lines
527 B
Plaintext
<CascadingAuthenticationState>
|
|
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
|
<Found Context="routeData">
|
|
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
|
<NotAuthorized>
|
|
<RedirectToLogin />
|
|
</NotAuthorized>
|
|
</AuthorizeRouteView>
|
|
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
|
</Found>
|
|
</Router>
|
|
</CascadingAuthenticationState>
|