fix(accounts): keep invalid accounts disabled

Require the silent activation refresh to return a valid account state before persisting the enabled setting. Invalid or expired sessions now roll back the optimistic toggle and cannot trigger an interactive login from active downloads.
This commit is contained in:
Sucukdeluxe
2026-08-15 21:43:30 +02:00
parent 82303dc94a
commit 31560cfbe0
3 changed files with 21 additions and 7 deletions
+12 -1
View File
@@ -141,7 +141,7 @@ describe("account activation refresh", () => {
const events: string[] = [];
await runAccountEnableRefresh(
async () => { events.push("check"); },
async () => { events.push("check"); return { valid: true, message: "Premium aktiv" }; },
async () => { events.push("persist"); }
);
@@ -158,4 +158,15 @@ describe("account activation refresh", () => {
expect(events).toEqual(["persist"]);
});
it("does not enable an account whose silent refresh is invalid", async () => {
const events: string[] = [];
await expect(runAccountEnableRefresh(
async () => { events.push("check"); return { valid: false, message: "Sitzung abgelaufen" }; },
async () => { events.push("persist"); }
)).rejects.toThrow("Sitzung abgelaufen");
expect(events).toEqual(["check"]);
});
});