1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-24 21:41:33 +01:00

[PM-2014] feat: add user verification to delete

This commit is contained in:
Andreas Coroiu 2023-05-11 10:22:25 +02:00
parent 09d09f7e3d
commit 90cd36b510
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
3 changed files with 11 additions and 5 deletions

View File

@ -35,7 +35,8 @@ export class WebauthnApiService {
return this.apiService.send("GET", "/webauthn", null, true, true);
}
deleteCredential(id: string): Promise<unknown> {
return this.apiService.send("DELETE", `/webauthn/${id}`, null, true, true);
async deleteCredential(credentialId: string, verification: Verification): Promise<void> {
const request = await this.userVerificationService.buildRequest(verification);
await this.apiService.send("POST", `/webauthn/${credentialId}/delete`, request, true, true);
}
}

View File

@ -114,9 +114,9 @@ export class WebauthnService {
);
}
async deleteCredential(credentialId: string): Promise<boolean> {
async deleteCredential(credentialId: string, verification: Verification): Promise<boolean> {
try {
await this.apiService.deleteCredential(credentialId);
await this.apiService.deleteCredential(credentialId, verification);
this.platformUtilsService.showToast("success", null, this.i18nService.t("passkeyRemoved"));
this.refresh();
return true;

View File

@ -4,6 +4,7 @@ import { FormBuilder, Validators } from "@angular/forms";
import { Subject, takeUntil } from "rxjs";
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
import { WebauthnService } from "../../../core";
import { WebauthnCredentialView } from "../../../core/views/webauth-credential.view";
@ -43,7 +44,11 @@ export class DeleteCredentialDialogComponent implements OnInit, OnDestroy {
}
this.dialogRef.disableClose = true;
if (!(await this.webauthnService.deleteCredential(this.credential.id))) {
const success = await this.webauthnService.deleteCredential(this.credential.id, {
type: VerificationType.MasterPassword,
secret: this.formGroup.value.masterPassword,
});
if (!success) {
this.dialogRef.disableClose = false;
return;
}