1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

[PM-5488] Master password re-prompt not triggering correctly from autofill action (#7590)

* [PM-5488] Master Password Re-prompt Not Triggering Correctly When Autofilling From Command

* [PM-5488] Master Password Re-prompt Not Triggering Correctly When Autofilling From Command

* [PM-5488] Adjusting how we handle debouncing the password reprompt window
This commit is contained in:
Cesar Gonzalez 2024-01-19 11:20:21 -06:00 committed by GitHub
parent d77e3c3352
commit d85485e5cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 8 deletions

View File

@ -909,6 +909,28 @@ describe("AutofillService", () => {
expect(autofillService.doAutoFill).not.toHaveBeenCalled();
expect(result).toBeNull();
});
it("skips autofill and does not launch the password reprompt window if the password reprompt is currently debouncing", async () => {
cipher.reprompt = CipherRepromptType.Password;
jest.spyOn(autofillService, "doAutoFill");
jest.spyOn(cipherService, "getNextCipherForUrl").mockResolvedValueOnce(cipher);
jest
.spyOn(userVerificationService, "hasMasterPasswordAndMasterKeyHash")
.mockResolvedValueOnce(true);
jest
.spyOn(autofillService as any, "openVaultItemPasswordRepromptPopout")
.mockImplementation();
jest
.spyOn(autofillService as any, "isDebouncingPasswordRepromptPopout")
.mockReturnValueOnce(true);
const result = await autofillService.doAutoFillOnTab(pageDetails, tab, true);
expect(cipherService.getNextCipherForUrl).toHaveBeenCalledWith(tab.url);
expect(autofillService["openVaultItemPasswordRepromptPopout"]).not.toHaveBeenCalled();
expect(autofillService.doAutoFill).not.toHaveBeenCalled();
expect(result).toBeNull();
});
});
});

View File

@ -332,10 +332,7 @@ export default class AutofillService implements AutofillServiceInterface {
return null;
}
if (
(await this.isPasswordRepromptRequired(cipher, tab)) &&
!this.isDebouncingPasswordRepromptPopout()
) {
if (await this.isPasswordRepromptRequired(cipher, tab)) {
if (fromCommand) {
this.cipherService.updateLastUsedIndexForUrl(tab.url);
}
@ -368,10 +365,12 @@ export default class AutofillService implements AutofillServiceInterface {
const userHasMasterPasswordAndKeyHash =
await this.userVerificationService.hasMasterPasswordAndMasterKeyHash();
if (cipher.reprompt === CipherRepromptType.Password && userHasMasterPasswordAndKeyHash) {
if (!this.isDebouncingPasswordRepromptPopout()) {
await this.openVaultItemPasswordRepromptPopout(tab, {
cipherId: cipher.id,
action: "autofill",
});
}
return true;
}