fix(web): unmount CustomerPortal when navigating to /login
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 <noreply@paperclip.ing>
This commit is contained in:
@@ -262,6 +262,9 @@ export function App() {
|
||||
return <Navigate to="/setup" replace />;
|
||||
}
|
||||
|
||||
// Don't render portal chrome at /login — DevLoginSelector is shown instead
|
||||
const showCustomerPortal = !location.pathname.startsWith("/admin") && location.pathname !== "/login";
|
||||
|
||||
return (
|
||||
<BrandingProvider>
|
||||
{location.pathname.startsWith("/admin") ? (
|
||||
@@ -271,12 +274,12 @@ export function App() {
|
||||
</Routes>
|
||||
{authDisabled && <DevSessionIndicator />}
|
||||
</>
|
||||
) : (
|
||||
) : showCustomerPortal ? (
|
||||
<>
|
||||
<CustomerPortal />
|
||||
{authDisabled && <DevSessionIndicator />}
|
||||
</>
|
||||
)}
|
||||
) : null}
|
||||
</BrandingProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user