From 0a270ca31a83a0da715fc7e59b98047bd94b0224 Mon Sep 17 00:00:00 2001 From: TrojanerHD Date: Sat, 24 Feb 2024 02:22:47 +0100 Subject: [PATCH] fix(frontend): show 2fa code field in login only if 2fa is enabled --- packages/client/src/components/MkSignin.vue | 38 ++++++++++----------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/client/src/components/MkSignin.vue b/packages/client/src/components/MkSignin.vue index 53d3c3d1b..4f5c6fcba 100644 --- a/packages/client/src/components/MkSignin.vue +++ b/packages/client/src/components/MkSignin.vue @@ -79,10 +79,10 @@ {{ i18n.ts.retry }} -
+

{{ i18n.ts.or }}

-
+

{{ i18n.ts.twoStepAuthentication }}

@@ -247,25 +247,23 @@ function queryKey() { function onSubmit() { signing.value = true; console.log("submit"); - if (!totpLogin.value && user.value && user.value.twoFactorEnabled) { - if (window.PublicKeyCredential && user.value.securityKeys) { - os.api("signin", { - username: username.value, - password: password.value, - "hcaptcha-response": hCaptchaResponse.value, - "g-recaptcha-response": reCaptchaResponse.value, + if (window.PublicKeyCredential && user.value.securityKeys) { + os.api("signin", { + username: username.value, + password: password.value, + "hcaptcha-response": hCaptchaResponse.value, + "g-recaptcha-response": reCaptchaResponse.value, + }) + .then((res) => { + totpLogin.value = true; + signing.value = false; + challengeData.value = res; + return queryKey(); }) - .then((res) => { - totpLogin.value = true; - signing.value = false; - challengeData.value = res; - return queryKey(); - }) - .catch(loginFailed); - } else { - totpLogin.value = true; - signing.value = false; - } + .catch(loginFailed); + } else if (!totpLogin.value && user.value && user.value.twoFactorEnabled) { + totpLogin.value = true; + signing.value = false; } else { os.api("signin", { username: username.value,