diff --git a/libs/vault/src/services/archive-cipher-utilities.service.spec.ts b/libs/vault/src/services/archive-cipher-utilities.service.spec.ts index 5df1bff9a56..ea00f482987 100644 --- a/libs/vault/src/services/archive-cipher-utilities.service.spec.ts +++ b/libs/vault/src/services/archive-cipher-utilities.service.spec.ts @@ -120,5 +120,19 @@ describe("ArchiveCipherUtilitiesService", () => { message: "errorOccurred", }); }); + + it("calls password reprompt check when unarchiving", async () => { + await service.unarchiveCipher(mockCipher); + + expect(passwordRepromptService.passwordRepromptCheck).toHaveBeenCalledWith(mockCipher); + }); + + it("returns early when password reprompt fails on unarchive", async () => { + passwordRepromptService.passwordRepromptCheck.mockResolvedValue(false); + + await service.unarchiveCipher(mockCipher); + + expect(cipherArchiveService.unarchiveWithServer).not.toHaveBeenCalled(); + }); }); }); diff --git a/libs/vault/src/services/archive-cipher-utilities.service.ts b/libs/vault/src/services/archive-cipher-utilities.service.ts index 93e752b57dd..b747961a701 100644 --- a/libs/vault/src/services/archive-cipher-utilities.service.ts +++ b/libs/vault/src/services/archive-cipher-utilities.service.ts @@ -74,7 +74,14 @@ export class ArchiveCipherUtilitiesService { * @param cipher The cipher to unarchive * @returns The unarchived cipher on success, or undefined on failure */ - async unarchiveCipher(cipher: CipherView) { + async unarchiveCipher(cipher: CipherView, skipReprompt = false) { + if (!skipReprompt) { + const repromptPassed = await this.passwordRepromptService.passwordRepromptCheck(cipher); + if (!repromptPassed) { + return; + } + } + const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); try { const cipherResponse = await this.cipherArchiveService.unarchiveWithServer(