From afd63c870144ac29c559ad46e5aca0a6632c1d1a Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Tue, 9 Jul 2024 15:40:53 -0700 Subject: [PATCH] [PM-8524] Add ability to remove passkey --- .../login-details-section.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts index d683587d1d8..f4dfed4b446 100644 --- a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts +++ b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts @@ -93,19 +93,20 @@ export class LoginDetailsSectionComponent implements OnInit { map(() => this.loginDetailsForm.getRawValue()), ) .subscribe((value) => { - const patchedLogin = Object.assign(this.loginView, { + Object.assign(this.loginView, { username: value.username, password: value.password, totp: value.totp, } as LoginView); this.cipherFormContainer.patchCipher({ - login: patchedLogin, + login: this.loginView, }); }); } async ngOnInit() { + this.loginView = new LoginView(); if (this.cipherFormContainer.originalCipherView?.login) { this.initFromExistingCipher(this.cipherFormContainer.originalCipherView.login); } else { @@ -118,7 +119,7 @@ export class LoginDetailsSectionComponent implements OnInit { } private initFromExistingCipher(existingLogin: LoginView) { - this.loginView = existingLogin; + Object.assign(this.loginView, existingLogin); this.loginDetailsForm.patchValue({ username: this.loginView.username, password: this.loginView.password, @@ -132,13 +133,18 @@ export class LoginDetailsSectionComponent implements OnInit { } private async initNewCipher() { - this.loginView = new LoginView(); - this.loginDetailsForm.controls.password.patchValue(await this.generateNewPassword()); } captureTotpFromTab = async () => {}; - removePasskey = async () => {}; + + removePasskey = async () => { + // Fido2Credentials do not have a form control, so update directly + this.loginView.fido2Credentials = null; + this.cipherFormContainer.patchCipher({ + login: this.loginView, + }); + }; private async generateNewPassword() { const [options] = await this.generatorService.getOptions();