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:
@@ -146,11 +146,14 @@ export async function runOptimisticAccountUpdate<T>(
|
||||
}
|
||||
|
||||
export async function runAccountEnableRefresh<T>(
|
||||
refresh: (() => Promise<void>) | undefined,
|
||||
refresh: (() => Promise<{ valid: boolean; message?: string }>) | undefined,
|
||||
persist: () => Promise<T>
|
||||
): Promise<T> {
|
||||
if (refresh) {
|
||||
await refresh();
|
||||
const status = await refresh();
|
||||
if (!status.valid) {
|
||||
throw new Error(status.message || "Accountprüfung fehlgeschlagen");
|
||||
}
|
||||
}
|
||||
return persist();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user