mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-18 01:41:27 +01:00
Bypass Master Password Reprompt if a user does not have a MP set (#5600)
* Add a check for a master password in PasswordRepromptService.enabled() * Add tests for enabled() * Update state service method call * Use UserVerificationService to determine if a user has a master password
This commit is contained in:
parent
d5102f1624
commit
98b5248bf3
@ -0,0 +1,34 @@
|
||||
import { MockProxy, mock } from "jest-mock-extended";
|
||||
|
||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||
|
||||
import { ModalService } from "../../services/modal.service";
|
||||
|
||||
import { PasswordRepromptService } from "./password-reprompt.service";
|
||||
|
||||
describe("PasswordRepromptService", () => {
|
||||
let passwordRepromptService: PasswordRepromptService;
|
||||
|
||||
let userVerificationService: MockProxy<UserVerificationService>;
|
||||
let modalService: MockProxy<ModalService>;
|
||||
|
||||
beforeEach(() => {
|
||||
modalService = mock<ModalService>();
|
||||
userVerificationService = mock<UserVerificationService>();
|
||||
|
||||
passwordRepromptService = new PasswordRepromptService(modalService, userVerificationService);
|
||||
});
|
||||
|
||||
describe("enabled()", () => {
|
||||
it("returns false if a user does not have a master password", async () => {
|
||||
userVerificationService.hasMasterPassword.mockResolvedValue(false);
|
||||
|
||||
expect(await passwordRepromptService.enabled()).toBe(false);
|
||||
});
|
||||
it("returns true if the user has a master password", async () => {
|
||||
userVerificationService.hasMasterPassword.mockResolvedValue(true);
|
||||
|
||||
expect(await passwordRepromptService.enabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/vault/abstractions/password-reprompt.service";
|
||||
|
||||
import { ModalService } from "../../services/modal.service";
|
||||
@ -16,7 +16,7 @@ export class PasswordRepromptService implements PasswordRepromptServiceAbstracti
|
||||
|
||||
constructor(
|
||||
private modalService: ModalService,
|
||||
private keyConnectorService: KeyConnectorService
|
||||
private userVerificationService: UserVerificationService
|
||||
) {}
|
||||
|
||||
protectedFields() {
|
||||
@ -39,6 +39,6 @@ export class PasswordRepromptService implements PasswordRepromptServiceAbstracti
|
||||
}
|
||||
|
||||
async enabled() {
|
||||
return !(await this.keyConnectorService.getUsesKeyConnector());
|
||||
return await this.userVerificationService.hasMasterPassword();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user