Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(auth): AuthInitializer not supporting cookie auth mode (#870)
Bohan Jiang8fb3bd322e6c
diff --git a/packages/core/platform/auth-initializer.tsx b/packages/core/platform/auth-initializer.tsxindex 7c2c18ceb7..ff216d2664 100644--- a/packages/core/platform/auth-initializer.tsx+++ b/packages/core/platform/auth-initializer.tsx@@ -17,15 +17,39 @@ export function AuthInitializer({onLogin,onLogout,storage = defaultStorage,+ cookieAuth,}: {children: ReactNode;onLogin?: () => void;onLogout?: () => void;storage?: StorageAdapter;+ cookieAuth?: boolean;}) {const qc = useQueryClient();useEffect(() => {+ const api = getApi();+ const wsId = storage.getItem("multica_workspace_id");++ if (cookieAuth) {+ // Cookie mode: the HttpOnly cookie is sent automatically by the browser.+ // Call the API to check if the session is still valid.+ Promise.all([api.getMe(), api.listWorkspaces()])+ .then(([user, wsList]) => {+ onLogin?.();+ useAuthStore.setState({ user, isLoading: false });+ qc.setQueryData(workspaceKeys.list(), wsList);+ useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);+ })+ .catch((err) => {+ logger.error("cookie auth init failed", err);+ onLogout?.();+ useAuthStore.setState({ user: null, isLoading: false });+ });+ return;+ }++ // Token mode: read from localStorage (Electron / legacy).const token = storage.getItem("multica_token");if (!token) {onLogout?.();@@ -33,9 +57,7 @@ export function AuthInitializer({return;}- const api = getApi();api.setToken(token);- const wsId = storage.getItem("multica_workspace_id");Promise.all([api.getMe(), api.listWorkspaces()]).then(([user, wsList]) => {diff --git a/packages/core/platform/core-provider.tsx b/packages/core/platform/core-provider.tsxindex 8df4b4f315..b6205c04cb 100644--- a/packages/core/platform/core-provider.tsx+++ b/packages/core/platform/core-provider.tsx@@ -74,7 +74,7 @@ export function CoreProvider({return (<QueryProvider>- <AuthInitializer onLogin={onLogin} onLogout={onLogout} storage={storage}>+ <AuthInitializer onLogin={onLogin} onLogout={onLogout} storage={storage} cookieAuth={cookieAuth}><WSProviderwsUrl={wsUrl}authStore={authStore}