fix feishu reauth for online docs

This commit is contained in:
wuyang6
2026-07-02 14:02:01 +08:00
parent 0007d99763
commit 8eadc25b19
5 changed files with 243 additions and 13 deletions
@@ -20,6 +20,7 @@ export async function POST(request: Request) {
const body = (await request.json().catch(() => ({}))) as {
action?: unknown;
force?: unknown;
};
const action = typeof body.action === "string" ? body.action : "login";
const endpoint =
@@ -30,7 +31,10 @@ export async function POST(request: Request) {
const response = await fetch(`${CLAW_API_URL}${endpoint}`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ account_id: account.id }),
body: JSON.stringify({
account_id: account.id,
...(action !== "logout" && body.force === true ? { force: true } : {}),
}),
cache: "no-store",
});
return proxyResponse(response);
@@ -574,10 +574,20 @@ function SessionFileRow({ file }: { file: SessionFile }) {
unknown
>;
if (response.status === 409) {
const detail = payload.detail;
const forceLogin =
Boolean(
detail &&
typeof detail === "object" &&
(detail as { force_login?: unknown }).force_login,
) ||
(detail &&
typeof detail === "object" &&
(detail as { code?: unknown }).code === "feishu_auth_expired");
const loginResponse = await fetch("/api/claw/integrations/feishu", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ action: "login" }),
body: JSON.stringify({ action: "login", force: forceLogin }),
});
const loginPayload = (await loginResponse
.json()