Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(auth): persist browser session during CLI login flow

Jiayuan Zhang857ec7d4d465
diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx
index 3419493345..f82532caaa 100644
--- a/apps/web/app/(auth)/login/page.tsx
+++ b/apps/web/app/(auth)/login/page.tsx
@@ -2,7 +2,7 @@
import { Suspense, useState, useEffect, useCallback } from "react";
import { useSearchParams, useRouter } from "next/navigation";
-import { useAuthStore } from "@/features/auth";
+import { useAuthStore, setLoggedInCookie } from "@/features/auth";
import { useWorkspaceStore } from "@/features/workspace";
import { api } from "@/shared/api";
import {
@@ -146,6 +146,10 @@ function LoginPageContent() {
return;
}
const { token } = await api.verifyCode(email, value);
+ // Persist session in the browser so the web app stays logged in
+ localStorage.setItem("multica_token", token);
+ api.setToken(token);
+ setLoggedInCookie();
const cliState = searchParams.get("cli_state") || "";
redirectToCliCallback(cliCallback, token, cliState);
return;
diff --git a/apps/web/features/auth/index.ts b/apps/web/features/auth/index.ts
index e0458c4847..8122213a91 100644
--- a/apps/web/features/auth/index.ts
+++ b/apps/web/features/auth/index.ts
@@ -1,2 +1,3 @@
export { useAuthStore } from "./store";
export { AuthInitializer } from "./initializer";
+export { setLoggedInCookie } from "./auth-cookie";