After re-login, the JWT is minted with the user's last-active tenant (see userService.resolveLoginTenantID). Both TenantSelector and UserMenu used to clear weknora_selected_tenant_id when "switching to home", which made request.ts stop attaching X-Tenant-ID. Without the header, the auth middleware fell back to the JWT-encoded tenant id — i.e. the peer tenant the user just tried to leave — so the switch was silently a no-op until the user manually wiped localStorage and re-logged in. Always write the active tenant id into selectedTenantId so the "always attach X-Tenant-ID" invariant request.ts relies on stays true. The server-side last_active_tenant_id preference is still cleared when switching to home, so a clean re-login still lands the user on home. Also fix TenantSelector.defaultTenantId to read user.tenant_id (the immutable home id) instead of authStore.tenant.id (the active tenant, which is overwritten by /auth/me). This matches the contract spelled out in useHomeTenant() and prevents switchingToHome from misfiring when the active tenant differs from home. |
||
|---|---|---|
| .. | ||
| packages | ||
| public | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| Dockerfile | ||
| docker-entrypoint.sh | ||
| env.d.ts | ||
| index.html | ||
| nginx.conf | ||
| package-lock.json | ||
| package.json | ||
| package.json.md5 | ||
| pnpm-workspace.yaml | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||