Merge p19-w1-t2-public-route-layout into dev (auth-state-driven DefaultLayout for public CMS routes)
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
AdditionalAssemblies="new[] { typeof(AuthBlocksWeb._Imports).Assembly }"
|
AdditionalAssemblies="new[] { typeof(AuthBlocksWeb._Imports).Assembly }"
|
||||||
NotFoundPage="typeof(NotFound)">
|
NotFoundPage="typeof(NotFound)">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="routeData"
|
<AuthorizeRouteView RouteData="routeData"
|
||||||
DefaultLayout="typeof(Layout.CmsLayout)">
|
DefaultLayout="@_currentLayout">
|
||||||
<NotAuthorized Context="authState">
|
<NotAuthorized Context="authState">
|
||||||
@if (authState.User.Identity?.IsAuthenticated == true)
|
@if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
{
|
{
|
||||||
@@ -18,3 +18,20 @@
|
|||||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||||
</Found>
|
</Found>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthenticationState { get; set; }
|
||||||
|
|
||||||
|
private Type _currentLayout = typeof(Layout.CmsHomeLayout);
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if (AuthenticationState is not null)
|
||||||
|
{
|
||||||
|
var authState = await AuthenticationState;
|
||||||
|
_currentLayout = authState.User.Identity?.IsAuthenticated == true
|
||||||
|
? typeof(Layout.CmsLayout)
|
||||||
|
: typeof(Layout.CmsHomeLayout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user