|
|
|
@ -239,22 +239,31 @@ export class ForceTwoFactorAuthLoginComponent extends PageComponent implements O |
|
|
|
saveConfig(type: TwoFactorAuthProviderType) { |
|
|
|
if (this.configForm.valid) { |
|
|
|
this.twoFaService.verifyAndSaveTwoFaAccountConfig(this.authAccountConfig, |
|
|
|
this.configForm.get('verificationCode').value).subscribe((config) => { |
|
|
|
switch (type) { |
|
|
|
case TwoFactorAuthProviderType.TOTP: |
|
|
|
this.appState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
case TwoFactorAuthProviderType.SMS: |
|
|
|
this.smsState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
case TwoFactorAuthProviderType.EMAIL: |
|
|
|
this.emailState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
this.configForm.get('verificationCode').value).subscribe({ |
|
|
|
next: (config) => { |
|
|
|
switch (type) { |
|
|
|
case TwoFactorAuthProviderType.TOTP: |
|
|
|
this.appState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
case TwoFactorAuthProviderType.SMS: |
|
|
|
this.smsState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
case TwoFactorAuthProviderType.EMAIL: |
|
|
|
this.emailState.set(ProvidersState.SUCCESS); |
|
|
|
break; |
|
|
|
} |
|
|
|
this.config = config; |
|
|
|
this.authAccountConfig = null; |
|
|
|
this.allowedProviders(); |
|
|
|
}, |
|
|
|
error: error => { |
|
|
|
if (error.status === 400) { |
|
|
|
this.configForm.get('verificationCode').setErrors({incorrectCode: true}); |
|
|
|
} else if (error.status === 429) { |
|
|
|
this.configForm.get('verificationCode').setErrors({tooManyRequest: true}); |
|
|
|
} |
|
|
|
} |
|
|
|
this.config = config; |
|
|
|
this.authAccountConfig = null; |
|
|
|
this.allowedProviders(); |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|