From 4b957b7e68625188a1ee281b9d7da1ee72d57c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9cile=20Vuilleumier?= Date: Wed, 16 Aug 2023 14:31:35 +0200 Subject: [PATCH] Add OTP field to login request if 2FA is activated --- src/auth/FormElement.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/auth/FormElement.ts b/src/auth/FormElement.ts index bc666dc7c1ee..5147f6f4cc08 100644 --- a/src/auth/FormElement.ts +++ b/src/auth/FormElement.ts @@ -477,12 +477,16 @@ export default class GmfAuthForm extends GmfBaseElement { if (pwdVal === '') { errors.push(i18next.t('The password is required.')); } + let otpVal = ''; + if (this.twoFactorAuth) { + otpVal = (form.otp as HTMLInputElement).value; + } if (errors.length) { this.isLoading = false; this.setError_(errors); } else { authenticationService - .login(loginVal, pwdVal) + .login(loginVal, pwdVal, otpVal) .then(() => { this.cleanForm_(); this.resetError_();