mirror of
https://github.com/bitwarden/browser
synced 2026-02-06 19:53:59 +00:00
[PM-2014] feat: add user verification to delete
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user