1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

[PM-8524] Add ability to remove passkey

This commit is contained in:
Shane Melton
2024-07-09 15:40:53 -07:00
parent faeda21021
commit afd63c8701

View File

@@ -93,19 +93,20 @@ export class LoginDetailsSectionComponent implements OnInit {
map(() => this.loginDetailsForm.getRawValue()), map(() => this.loginDetailsForm.getRawValue()),
) )
.subscribe((value) => { .subscribe((value) => {
const patchedLogin = Object.assign(this.loginView, { Object.assign(this.loginView, {
username: value.username, username: value.username,
password: value.password, password: value.password,
totp: value.totp, totp: value.totp,
} as LoginView); } as LoginView);
this.cipherFormContainer.patchCipher({ this.cipherFormContainer.patchCipher({
login: patchedLogin, login: this.loginView,
}); });
}); });
} }
async ngOnInit() { async ngOnInit() {
this.loginView = new LoginView();
if (this.cipherFormContainer.originalCipherView?.login) { if (this.cipherFormContainer.originalCipherView?.login) {
this.initFromExistingCipher(this.cipherFormContainer.originalCipherView.login); this.initFromExistingCipher(this.cipherFormContainer.originalCipherView.login);
} else { } else {
@@ -118,7 +119,7 @@ export class LoginDetailsSectionComponent implements OnInit {
} }
private initFromExistingCipher(existingLogin: LoginView) { private initFromExistingCipher(existingLogin: LoginView) {
this.loginView = existingLogin; Object.assign(this.loginView, existingLogin);
this.loginDetailsForm.patchValue({ this.loginDetailsForm.patchValue({
username: this.loginView.username, username: this.loginView.username,
password: this.loginView.password, password: this.loginView.password,
@@ -132,13 +133,18 @@ export class LoginDetailsSectionComponent implements OnInit {
} }
private async initNewCipher() { private async initNewCipher() {
this.loginView = new LoginView();
this.loginDetailsForm.controls.password.patchValue(await this.generateNewPassword()); this.loginDetailsForm.controls.password.patchValue(await this.generateNewPassword());
} }
captureTotpFromTab = async () => {}; 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() { private async generateNewPassword() {
const [options] = await this.generatorService.getOptions(); const [options] = await this.generatorService.getOptions();