diff --git a/DeepDrftManager/Components/Routes.razor b/DeepDrftManager/Components/Routes.razor index 289efc1..19212b0 100644 --- a/DeepDrftManager/Components/Routes.razor +++ b/DeepDrftManager/Components/Routes.razor @@ -2,8 +2,8 @@ AdditionalAssemblies="new[] { typeof(AuthBlocksWeb._Imports).Assembly }" NotFoundPage="typeof(NotFound)"> - + @if (authState.User.Identity?.IsAuthenticated == true) { @@ -18,3 +18,20 @@ + +@code { + [CascadingParameter] private Task? 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); + } + } +}