diff --git a/www/js/loginform.js b/www/js/loginform.js index 4d55780b321f4402f439cb126a5ebbce2d4821dc..e5e2b716cb9e6b782847f22a30f3ea05c7ecfcf2 100644 --- a/www/js/loginform.js +++ b/www/js/loginform.js @@ -60,6 +60,14 @@ function changeMode(newMode) { document.forms["piLoginForm"].submit(); } +function fallbackToOTP() { + if (value("mode") !== "otp") { + setTimeout(() => { + changeMode("otp"); + }, 3000); + } +} + function setMessage(newMessage) { getElement("message").innerText = newMessage; } @@ -113,14 +121,14 @@ function doWebAuthn() { console.log( "Insecure context detected: Aborting Web Authn authentication!" ); - changeMode("otp"); + fallbackToOTP(); return; } if (!window.pi_webauthn) { enable("useWebAuthnButton"); setMessage(t("webauthn_library_unavailable")); - changeMode("otp"); + fallbackToOTP(); return; } @@ -163,7 +171,7 @@ function doU2F() { if (!window.isSecureContext) { setMessage(t("u2f_insecure_context")); console.log("Insecure context detected: Aborting U2F authentication!"); - changeMode("otp"); + fallbackToOTP(); return; } @@ -171,7 +179,7 @@ function doU2F() { if (requestStr === null) { setMessage(t("u2f_unavailable")); - changeMode("otp"); + fallbackToOTP(); return; }