From ac6814a66dfe5b0c3d82dd00889b76540234d6be Mon Sep 17 00:00:00 2001 From: thxforall <113906780+thxforall@users.noreply.github.com> Date: Thu, 23 Apr 2026 20:24:27 +0900 Subject: [PATCH] fix(admin): redirect to /admin/login after logout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AdminSidebar's handleLogout only cleared client auth state via the store. AdminLayout is a React Server Component so it does not re-render on client state changes — the admin chrome stayed on screen with stale data until a hard navigation. The DELETE /api/auth/session call was returning 200 but the user saw no visual change. Fix: after `logout()` resolves, call `router.replace("/admin/login")` so the route transitions client-side and the server layout re-runs with no user, falling back to the login page. --- packages/web/lib/components/admin/AdminSidebar.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/web/lib/components/admin/AdminSidebar.tsx b/packages/web/lib/components/admin/AdminSidebar.tsx index 2b98ce8e..f86447dd 100644 --- a/packages/web/lib/components/admin/AdminSidebar.tsx +++ b/packages/web/lib/components/admin/AdminSidebar.tsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; -import { usePathname } from "next/navigation"; +import { usePathname, useRouter } from "next/navigation"; import { Activity, ArrowLeft, @@ -128,10 +128,15 @@ export function AdminSidebar({ adminName, }: AdminSidebarProps) { const pathname = usePathname(); + const router = useRouter(); const logout = useAuthStore((state) => state.logout); - function handleLogout() { - logout(); + async function handleLogout() { + // AdminLayout is a Server Component — it does not re-render on client + // auth state changes. After signing out we must push to /admin/login + // ourselves, otherwise the admin chrome stays visible with stale data. + await logout(); + router.replace("/admin/login"); } return (