fix(auth): preserve last workspace ID across re-login

The logout handler was clearing `multica_workspace_id` from storage,
so re-login always defaulted to the first workspace. The workspace ID
is a user preference, not session-sensitive data — keep it so both
web and desktop restore the correct workspace after re-authentication.

Also pass `lastWorkspaceId` in the desktop login page, which was
previously missing.
This commit is contained in:
Jiayuan Zhang
2026-04-12 17:04:25 +08:00
parent 9ed80120e0
commit ae4eed3b7d
2 changed files with 3 additions and 1 deletions

View File

@@ -2,6 +2,8 @@ import { LoginPage } from "@multica/views/auth";
import { MulticaIcon } from "@multica/ui/components/common/multica-icon";
export function DesktopLoginPage() {
const lastWorkspaceId = localStorage.getItem("multica_workspace_id");
return (
<div className="flex h-screen flex-col">
{/* Traffic light inset */}
@@ -11,6 +13,7 @@ export function DesktopLoginPage() {
/>
<LoginPage
logo={<MulticaIcon bordered size="lg" />}
lastWorkspaceId={lastWorkspaceId}
onSuccess={() => {
// Auth store update triggers AppContent re-render → shows DesktopShell
}}

View File

@@ -72,7 +72,6 @@ export function createAuthStore(options: AuthStoreOptions) {
logout: () => {
storage.removeItem("multica_token");
storage.removeItem("multica_workspace_id");
api.setToken(null);
api.setWorkspaceId(null);
onLogout?.();