From 3485acf3a8d6b56efbcceb908b77480d3e36bbbb Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Fri, 19 Jun 2026 21:16:42 -0400 Subject: [PATCH] feat: auth-state-driven DefaultLayout for CMS public routes Resolve Routes.razor DefaultLayout from cascaded AuthenticationState so unauthenticated AuthBlocks pages (/account/login, /account/register) render in lean CmsHomeLayout instead of the authenticated CmsLayout shell. --- DeepDrftManager/Components/Routes.razor | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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); + } + } +}