1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-17 16:03:20 +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

@@ -17,30 +17,20 @@ export class PowerMonitorMain {
// ref: https://github.com/electron/electron/issues/13767
if (!isSnapStore()) {
// System sleep
powerMonitor.on("suspend", async () => {
const options = await this.getVaultTimeoutOptions();
if (options[0] === -3) {
options[1] === "logOut"
? this.main.messagingService.send("logout", { expired: false })
: this.main.messagingService.send("lockVault");
}
powerMonitor.on("suspend", () => {
this.main.messagingService.send("systemSuspended");
});
}
if (process.platform !== "linux") {
// System locked
powerMonitor.on("lock-screen", async () => {
const options = await this.getVaultTimeoutOptions();
if (options[0] === -2) {
options[1] === "logOut"
? this.main.messagingService.send("logout", { expired: false })
: this.main.messagingService.send("lockVault");
}
powerMonitor.on("lock-screen", () => {
this.main.messagingService.send("systemLocked");
});
}
// System idle
global.setInterval(async () => {
global.setInterval(() => {
const idleSeconds: number = powerMonitor.getSystemIdleTime();
const idle = idleSeconds >= IdleLockSeconds;
if (idle) {
@@ -48,21 +38,10 @@ export class PowerMonitorMain {
return;
}
const options = await this.getVaultTimeoutOptions();
if (options[0] === -4) {
options[1] === "logOut"
? this.main.messagingService.send("logout", { expired: false })
: this.main.messagingService.send("lockVault");
}
this.main.messagingService.send("systemIdle");
}
this.idle = idle;
}, IdleCheckInterval);
}
private async getVaultTimeoutOptions(): Promise<[number, string]> {
const timeout = await this.main.stateService.getVaultTimeout();
const action = await this.main.stateService.getVaultTimeoutAction();
return [timeout, action];
}
}