1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

[bug] Inactive accounts with power-based timeout settings are not timing out (#1278)

* [bug] Move bulk of system lock checks into app.component

* [review] Extract shared system timeout logic

* [review] Correct an improper number

* [review] Opt for a more locally scoped system timeout helper than a dedicated enum
This commit is contained in:
Addison Beck
2022-02-01 11:31:30 -05:00
committed by GitHub
parent 2b22a39d45
commit 48ff9f61ae
2 changed files with 38 additions and 27 deletions

View File

@@ -53,6 +53,12 @@ const BroadcasterSubscriptionId = "AppComponent";
const IdleTimeout = 60000 * 10; // 10 minutes
const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours
const systemTimeoutOptions = {
onLock: -2,
onSuspend: -3,
onIdle: -4,
};
@Component({
selector: "app-root",
styles: [],
@@ -339,6 +345,12 @@ export class AppComponent implements OnInit {
this.router.navigate(["vault"]);
}
break;
case "systemSuspended":
await this.checkForSystemTimeout(systemTimeoutOptions.onSuspend);
case "systemLocked":
await this.checkForSystemTimeout(systemTimeoutOptions.onLock);
case "systemIdle":
await this.checkForSystemTimeout(systemTimeoutOptions.onIdle);
}
});
});
@@ -583,4 +595,24 @@ export class AppComponent implements OnInit {
}
await this.systemService.startProcessReload();
}
private async checkForSystemTimeout(timeout: number): Promise<void> {
for (const userId in this.stateService.accounts.getValue()) {
if (userId == null) {
continue;
}
const options = await this.getVaultTimeoutOptions(userId);
if (options[0] === timeout) {
options[1] === "logOut"
? this.logOut(false, userId)
: await this.vaultTimeoutService.lock(true, userId);
}
}
}
private async getVaultTimeoutOptions(userId: string): Promise<[number, string]> {
const timeout = await this.stateService.getVaultTimeout({ userId: userId });
const action = await this.stateService.getVaultTimeoutAction({ userId: userId });
return [timeout, action];
}
}