1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

[PM-14965] Fix password reprompt for context menu actions (#12213)

* [PM-14965] Add return value for copy-cipher-field.service

* [PM-14965] Cleanup loadAction handling in updated browser view item page

* [PM-14965] Fix unit tests

* [PM-14965] Clear copy mock
This commit is contained in:
Shane Melton
2024-12-03 09:37:44 -08:00
committed by GitHub
parent 9188a31b4a
commit 60e52dd2f2
4 changed files with 185 additions and 23 deletions

View File

@@ -95,13 +95,15 @@ export class CopyCipherFieldService {
* @param actionType The type of field being copied.
* @param cipher The cipher containing the field to copy.
* @param skipReprompt Whether to skip password re-prompting.
*
* @returns Whether the field was copied successfully.
*/
async copy(
valueToCopy: string,
actionType: CopyAction,
cipher: CipherView,
skipReprompt: boolean = false,
) {
): Promise<boolean> {
const action = CopyActions[actionType];
if (
!skipReprompt &&
@@ -109,16 +111,16 @@ export class CopyCipherFieldService {
action.protected &&
!(await this.passwordRepromptService.showPasswordPrompt())
) {
return;
return false;
}
if (valueToCopy == null) {
return;
return false;
}
if (actionType === "totp") {
if (!(await this.totpAllowed(cipher))) {
return;
return false;
}
valueToCopy = await this.totpService.getCode(valueToCopy);
}
@@ -138,6 +140,8 @@ export class CopyCipherFieldService {
cipher.organizationId,
);
}
return true;
}
/**