1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

PM-5501 - VaultTimeoutSettingsSvc State Provider Migration - Small bugfixes (#9164)

* PM-5501 - VaultTimeoutSettingsSvc - fix setVaultTimeoutOptions condition which needed to use never instead of null.

* PM-5501 - Fix browser and desktop not showing the never lock warning

* PM-5501 - Use true equality.
This commit is contained in:
Jared Snider 2024-05-13 17:04:26 -04:00 committed by GitHub
parent bf57a181eb
commit 66f5d90803
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 6 deletions

View File

@ -254,7 +254,7 @@ export class AccountSecurityComponent implements OnInit {
} }
async saveVaultTimeout(previousValue: VaultTimeout, newValue: VaultTimeout) { async saveVaultTimeout(previousValue: VaultTimeout, newValue: VaultTimeout) {
if (newValue == null) { if (newValue === VaultTimeoutStringType.Never) {
const confirmed = await this.dialogService.openSimpleDialog({ const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "warning" }, title: { key: "warning" },
content: { key: "neverLockWarning" }, content: { key: "neverLockWarning" },
@ -289,7 +289,7 @@ export class AccountSecurityComponent implements OnInit {
newValue, newValue,
vaultTimeoutAction, vaultTimeoutAction,
); );
if (newValue == null) { if (newValue === VaultTimeoutStringType.Never) {
this.messagingService.send("bgReseedStorage"); this.messagingService.send("bgReseedStorage");
} }
} }

View File

@ -371,7 +371,7 @@ export class SettingsComponent implements OnInit {
} }
async saveVaultTimeout(newValue: VaultTimeout) { async saveVaultTimeout(newValue: VaultTimeout) {
if (newValue == null) { if (newValue === VaultTimeoutStringType.Never) {
const confirmed = await this.dialogService.openSimpleDialog({ const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "warning" }, title: { key: "warning" },
content: { key: "neverLockWarning" }, content: { key: "neverLockWarning" },

View File

@ -313,7 +313,7 @@ describe("VaultTimeoutSettingsService", () => {
expect(cryptoService.refreshAdditionalKeys).toHaveBeenCalled(); expect(cryptoService.refreshAdditionalKeys).toHaveBeenCalled();
}); });
it("should clear the tokens when the timeout is non-null and the action is log out", async () => { it("should clear the tokens when the timeout is not never and the action is log out", async () => {
// Arrange // Arrange
const action = VaultTimeoutAction.LogOut; const action = VaultTimeoutAction.LogOut;
const timeout = 30; const timeout = 30;
@ -324,6 +324,18 @@ describe("VaultTimeoutSettingsService", () => {
// Assert // Assert
expect(tokenService.clearTokens).toHaveBeenCalled(); expect(tokenService.clearTokens).toHaveBeenCalled();
}); });
it("should not clear the tokens when the timeout is never and the action is log out", async () => {
// Arrange
const action = VaultTimeoutAction.LogOut;
const timeout = VaultTimeoutStringType.Never;
// Act
await vaultTimeoutSettingsService.setVaultTimeoutOptions(mockUserId, timeout, action);
// Assert
expect(tokenService.clearTokens).not.toHaveBeenCalled();
});
}); });
function createVaultTimeoutSettingsService( function createVaultTimeoutSettingsService(

View File

@ -30,7 +30,7 @@ import { LogService } from "../../platform/abstractions/log.service";
import { BiometricStateService } from "../../platform/biometrics/biometric-state.service"; import { BiometricStateService } from "../../platform/biometrics/biometric-state.service";
import { StateProvider } from "../../platform/state"; import { StateProvider } from "../../platform/state";
import { UserId } from "../../types/guid"; import { UserId } from "../../types/guid";
import { VaultTimeout } from "../../types/vault-timeout.type"; import { VaultTimeout, VaultTimeoutStringType } from "../../types/vault-timeout.type";
import { VAULT_TIMEOUT, VAULT_TIMEOUT_ACTION } from "./vault-timeout-settings.state"; import { VAULT_TIMEOUT, VAULT_TIMEOUT_ACTION } from "./vault-timeout-settings.state";
@ -74,7 +74,7 @@ export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceA
await this.setVaultTimeout(userId, timeout); await this.setVaultTimeout(userId, timeout);
if (timeout != null && action === VaultTimeoutAction.LogOut) { if (timeout != VaultTimeoutStringType.Never && action === VaultTimeoutAction.LogOut) {
// if we have a vault timeout and the action is log out, reset tokens // if we have a vault timeout and the action is log out, reset tokens
// as the tokens were stored on disk and now should be stored in memory // as the tokens were stored on disk and now should be stored in memory
await this.tokenService.clearTokens(); await this.tokenService.clearTokens();