From 22475ae8e22ed8eb49e165fefb9f1521d2dde0bd Mon Sep 17 00:00:00 2001 From: "groombook-engineer[bot]" <3141748+groombook-engineer[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:22:45 +0000 Subject: [PATCH] fix(web): unmount CustomerPortal when navigating to /login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user was logged in as one client and switched to another via the dev login selector, the portal pages (Home, My Pets, Appointments, Billing) continued showing the original user's data. Root cause: CustomerPortal was rendered unconditionally for all non-/admin routes (including /login). Since CustomerPortal uses a ref (initDone) to skip re-initialization on re-renders, navigating to /login and back did not trigger session re-creation — the old session remained in state. Fix: make CustomerPortal conditional on pathname not being /login, so it properly unmounts when the user switches. On re-navigation to /, a fresh CustomerPortal mounts and creates a new session for the selected dev user. Co-Authored-By: Paperclip --- apps/web/src/App.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index a8f7b2a..b0ac1c7 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -262,6 +262,9 @@ export function App() { return ; } + // Don't render portal chrome at /login — DevLoginSelector is shown instead + const showCustomerPortal = !location.pathname.startsWith("/admin") && location.pathname !== "/login"; + return ( {location.pathname.startsWith("/admin") ? ( @@ -271,12 +274,12 @@ export function App() { {authDisabled && } - ) : ( + ) : showCustomerPortal ? ( <> {authDisabled && } - )} + ) : null} ); }