fix(qq): preserve login and playback key expiry

This commit is contained in:
NoSetViolin committed 2026-11-11 11:09:42 +09:00
1 parent 72e0d3a439
commit c3d06cb09a
8 files changed
+136 -22

No files matched your search

+10
View File
@@ -130,4 +130,14 @@ describe("managed QQ authentication routes", () => {
expect(legacyStore.save).toHaveBeenCalledWith("qq", "private-test-cookie");
await request(app).post("/api/auth/qq/refresh").expect(404);
});
it("keeps the current QQ cookie when an unmanaged import cannot be saved", async () => {
const { app, qq, legacyStore } = mount(false);
legacyStore.save.mockImplementationOnce(() => { throw new Error("test write failed"); });
await request(app).post("/api/auth/cookie").send({ platform: "qq", cookie: "uin=999" }).expect(503);
expect(qq.setCookie).not.toHaveBeenCalled();
await request(app).post("/api/auth/cookie").send({ platform: "qq", cookie: "uin=999" }).expect(200);
expect(legacyStore.save).toHaveBeenLastCalledWith("qq", "uin=999");
expect(qq.setCookie).toHaveBeenCalledWith("uin=999");
});
});
+3 -2
View File
@@ -212,8 +212,9 @@ export function createAuthRouter(
return;
}
const provider = getProvider(platform);
if (platform === "qq" && qqSession) {
if (platform === "qq") {
try {
if (!qqSession) cookieStore?.save("qq", cookie);
provider.setCookie(cookie);
res.json({ success: true });
} catch {
@@ -225,7 +226,7 @@ export function createAuthRouter(
provider.setCookie(cookie);
const plat = platform === "bilibili" ? "bilibili" as const
: platform === "kugou" ? "kugou" as const
: platform === "qq" ? "qq" as const : "netease" as const;
: "netease" as const;
if (cookieStore) {
cookieStore.save(plat, cookie);
}