1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01: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, this.dialogService,
{ data: result }, { data: result },
); );
this.twoFactorSetupSubscription = webAuthnComp.componentInstance.onChangeStatus this.twoFactorSetupSubscription = webAuthnComp.componentInstance.onUpdated
.pipe(first(), takeUntil(this.destroy$)) .pipe(first(), takeUntil(this.destroy$))
.subscribe((enabled: boolean) => { .subscribe((enabled: boolean) => {
webAuthnComp.close(); webAuthnComp.close();

View File

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