1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-9631] MP reprompt view items (#10291)

* MP reprompt check will run before viewing item
This commit is contained in:
Jason Ng
2024-07-29 16:08:35 -04:00
committed by GitHub
parent 2eea253dac
commit 3b668deaac
7 changed files with 28 additions and 43 deletions

View File

@@ -25,7 +25,7 @@
{{ favoriteText | i18n }}
</button>
<ng-container *ngIf="canEdit">
<a routerLink="" bitMenuItem (click)="clone()">
<a bitMenuItem (click)="clone()">
{{ "clone" | i18n }}
</a>
<a bitMenuItem (click)="conditionallyNavigateToAssignCollections()">

View File

@@ -76,6 +76,13 @@ export class ItemMoreOptionsComponent {
}
async doAutofillAndSave() {
if (
this.cipher.reprompt === CipherRepromptType.Password &&
!(await this.passwordRepromptService.showPasswordPrompt())
) {
return;
}
await this.vaultPopupAutofillService.doAutofillAndSave(this.cipher);
}

View File

@@ -20,8 +20,7 @@
<bit-item *ngFor="let cipher of ciphers">
<a
bit-item-content
[routerLink]="['/view-cipher']"
[queryParams]="{ cipherId: cipher.id, type: cipher.type }"
(click)="onViewCipher(cipher)"
[appA11yTitle]="'viewItemTitle' | i18n: cipher.name"
>
<app-vault-icon slot="start" [cipher]="cipher"></app-vault-icon>

View File

@@ -1,6 +1,6 @@
import { CommonModule } from "@angular/common";
import { booleanAttribute, Component, EventEmitter, Input, Output } from "@angular/core";
import { RouterLink } from "@angular/router";
import { Router, RouterLink } from "@angular/router";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -13,7 +13,7 @@ import {
SectionHeaderComponent,
TypographyModule,
} from "@bitwarden/components";
import { OrgIconDirective } from "@bitwarden/vault";
import { OrgIconDirective, PasswordRepromptService } from "@bitwarden/vault";
import { VaultPopupAutofillService } from "../../../services/vault-popup-autofill.service";
import { PopupCipherView } from "../../../views/popup-cipher.view";
@@ -100,9 +100,22 @@ export class VaultListItemsContainerComponent {
constructor(
private i18nService: I18nService,
private vaultPopupAutofillService: VaultPopupAutofillService,
private passwordRepromptService: PasswordRepromptService,
private router: Router,
) {}
async doAutofill(cipher: PopupCipherView) {
await this.vaultPopupAutofillService.doAutofill(cipher);
}
async onViewCipher(cipher: PopupCipherView) {
const repromptPassed = await this.passwordRepromptService.passwordRepromptCheck(cipher);
if (!repromptPassed) {
return;
}
await this.router.navigate(["/view-cipher"], {
queryParams: { cipherId: cipher.id, type: cipher.type },
});
}
}

View File

@@ -22,7 +22,6 @@ import {
DialogService,
ToastService,
} from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";
import { CipherViewComponent } from "../../../../../../../../libs/vault/src/cipher-view";
@@ -55,14 +54,12 @@ export class ViewV2Component {
organization$: Observable<Organization>;
folder$: Observable<FolderView>;
collections$: Observable<CollectionView[]>;
private passwordReprompted = false;
constructor(
private route: ActivatedRoute,
private router: Router,
private i18nService: I18nService,
private cipherService: CipherService,
private passwordRepromptService: PasswordRepromptService,
private dialogService: DialogService,
private logService: LogService,
private toastService: ToastService,
@@ -102,20 +99,7 @@ export class ViewV2Component {
return await cipher.decrypt(await this.cipherService.getKeyForCipherKeyDecryption(cipher));
}
async checkForPasswordReprompt() {
this.passwordReprompted =
this.passwordReprompted ||
(await this.passwordRepromptService.passwordRepromptCheck(this.cipher));
if (!this.passwordReprompted) {
return false;
}
return true;
}
async editCipher() {
if (!(await this.checkForPasswordReprompt())) {
return;
}
if (this.cipher.isDeleted) {
return false;
}
@@ -126,10 +110,6 @@ export class ViewV2Component {
}
delete = async (): Promise<boolean> => {
if (!(await this.checkForPasswordReprompt())) {
return;
}
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "deleteItem" },
content: {