mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
toast is how showing; removed event emitter to use built in emitter in base class; (#10761)
This commit is contained in:
parent
a5ea22d0cc
commit
b264a3f442
@ -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();
|
||||
|
@ -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;
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user