1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-25 21:51:30 +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); return this.apiService.send("GET", "/webauthn", null, true, true);
} }
deleteCredential(id: string): Promise<unknown> { async deleteCredential(credentialId: string, verification: Verification): Promise<void> {
return this.apiService.send("DELETE", `/webauthn/${id}`, null, true, true); 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 { try {
await this.apiService.deleteCredential(credentialId); await this.apiService.deleteCredential(credentialId, verification);
this.platformUtilsService.showToast("success", null, this.i18nService.t("passkeyRemoved")); this.platformUtilsService.showToast("success", null, this.i18nService.t("passkeyRemoved"));
this.refresh(); this.refresh();
return true; return true;

View File

@ -4,6 +4,7 @@ import { FormBuilder, Validators } from "@angular/forms";
import { Subject, takeUntil } from "rxjs"; import { Subject, takeUntil } from "rxjs";
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog"; import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
import { WebauthnService } from "../../../core"; import { WebauthnService } from "../../../core";
import { WebauthnCredentialView } from "../../../core/views/webauth-credential.view"; import { WebauthnCredentialView } from "../../../core/views/webauth-credential.view";
@ -43,7 +44,11 @@ export class DeleteCredentialDialogComponent implements OnInit, OnDestroy {
} }
this.dialogRef.disableClose = true; 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; this.dialogRef.disableClose = false;
return; return;
} }