Fix Cancel Authentication popup

This commit is contained in:
Jack Anderson 2024-11-25 10:16:14 +00:00
parent acbfb0b025
commit 5ba989392d

View file

@ -91,7 +91,7 @@ export class TwoFactorComponent implements OnInit {
this.enableAppMethodButtonConfig = { this.enableAppMethodButtonConfig = {
klass: 'btn btn-sm btn-main', klass: 'btn btn-sm btn-main',
onClick: ((): void => { onClick: ((): void => {
this.enable2FactorAuth() this.enable2fa()
}) as ButtonCallback, }) as ButtonCallback,
labelKey: 'LBL_ENABLE', labelKey: 'LBL_ENABLE',
titleKey: '' titleKey: ''
@ -109,7 +109,7 @@ export class TwoFactorComponent implements OnInit {
this.cancelAppMethodTButtonConfig = { this.cancelAppMethodTButtonConfig = {
klass: 'btn btn-sm btn-main', klass: 'btn btn-sm btn-main',
onClick: ((): void => { onClick: ((): void => {
this.disable2FactorAuth() this.cancel2fa()
}) as ButtonCallback, }) as ButtonCallback,
labelKey: 'LBL_CANCEL', labelKey: 'LBL_CANCEL',
titleKey: '' titleKey: ''
@ -125,7 +125,7 @@ export class TwoFactorComponent implements OnInit {
} as ButtonInterface; } as ButtonInterface;
} }
public enable2FactorAuth(): void { public enable2fa(): void {
this.authService.enable2fa().subscribe({ this.authService.enable2fa().subscribe({
next: (response) => { next: (response) => {
@ -145,34 +145,42 @@ export class TwoFactorComponent implements OnInit {
public disable2FactorAuth(): void { public disable2FactorAuth(): void {
const modal = this.modalService.open(TwoFactorCheckModalComponent, {size: 'lg'}); const modal = this.modalService.open(TwoFactorCheckModalComponent, {size: 'lg'});
modal.result.then((result) => { modal.result.then((result) => {
if (!result.two_factor_complete){ if (!result.two_factor_complete){
this.message.addDangerMessageByKey('LBL_FACTOR_AUTH_FAIL'); this.message.addDangerMessageByKey('LBL_FACTOR_AUTH_FAIL');
return; return;
} }
this.authService.disable2fa().subscribe({ this.disable2fa();
next: (response) => {
if (isTrue(response?.two_factor_disabled)) {
this.isAppMethodEnabled.set(false);
this.areRecoveryCodesGenerated.set(false);
this.isQrCodeGenerated.set(false);
this.message.addSuccessMessageByKey('LBL_FACTOR_AUTH_DISABLE');
}
},
error: () => {
this.isAppMethodEnabled.set(true);
this.areRecoveryCodesGenerated.set(true);
}
});
return; return;
}).catch(); }).catch();
} }
public cancel2fa(): void {
this.disable2fa();
}
public disable2fa(): void {
this.authService.disable2fa().subscribe({
next: (response) => {
if (isTrue(response?.two_factor_disabled)) {
this.isAppMethodEnabled.set(false);
this.areRecoveryCodesGenerated.set(false);
this.isQrCodeGenerated.set(false);
this.message.addSuccessMessageByKey('LBL_FACTOR_AUTH_DISABLE');
}
},
error: () => {
this.isAppMethodEnabled.set(true);
this.areRecoveryCodesGenerated.set(true);
}
});
}
getTitle(): string { getTitle(): string {
return this.title; return this.title;
} }