1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-23 03:22:50 +02:00

toast is how showing; removed event emitter to use built in emitter in base class; (#10761)

This commit is contained in:
Ike 2024-09-04 12:49:18 -07:00 committed by GitHub
parent a5ea22d0cc
commit b264a3f442
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 18 deletions

View File

@ -220,7 +220,7 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy {
this.dialogService,
{ data: result },
);
this.twoFactorSetupSubscription = webAuthnComp.componentInstance.onChangeStatus
this.twoFactorSetupSubscription = webAuthnComp.componentInstance.onUpdated
.pipe(first(), takeUntil(this.destroy$))
.subscribe((enabled: boolean) => {
webAuthnComp.close();

View File

@ -1,5 +1,5 @@
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
import { Component, EventEmitter, Inject, NgZone, Output } from "@angular/core";
import { Component, Inject, NgZone } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
@ -33,7 +33,6 @@ interface Key {
templateUrl: "two-factor-webauthn.component.html",
})
export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
@Output() onChangeStatus = new EventEmitter<boolean>();
type = TwoFactorProviderType.WebAuthn;
name: string;
keys: Key[];
@ -85,34 +84,33 @@ export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
// Should never happen.
return Promise.reject();
}
return this.enable();
};
protected async enable() {
const request = await this.buildRequestModel(UpdateTwoFactorWebAuthnRequest);
request.deviceResponse = this.webAuthnResponse;
request.id = this.keyIdAvailable;
request.name = this.formGroup.value.name;
return this.enableWebAuth(request);
};
private enableWebAuth(request: any) {
return super.enable(async () => {
this.formPromise = this.apiService.putTwoFactorWebAuthn(request);
const response = await this.formPromise;
this.processResponse(response);
const response = await this.apiService.putTwoFactorWebAuthn(request);
this.processResponse(response);
this.toastService.showToast({
title: this.i18nService.t("success"),
message: this.i18nService.t("twoFactorProviderEnabled"),
variant: "success",
});
this.onUpdated.emit(response.enabled);
}
disable = async () => {
await this.disableWebAuth();
await this.disableMethod();
if (!this.enabled) {
this.onChangeStatus.emit(this.enabled);
this.onUpdated.emit(this.enabled);
this.dialogRef.close();
}
};
private async disableWebAuth() {
return super.disable(this.formPromise);
}
async remove(key: Key) {
if (this.keysConfiguredCount <= 1 || key.removePromise != null) {
return;
@ -208,7 +206,7 @@ export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
}
}
this.enabled = response.enabled;
this.onChangeStatus.emit(this.enabled);
this.onUpdated.emit(this.enabled);
}
static open(