fix: 🐛 2fa verification

This commit is contained in:
2025-12-27 02:23:28 +00:00
parent 91067994ba
commit 53dc19a549
2 changed files with 43 additions and 4 deletions
+28 -3
View File
@@ -81,14 +81,39 @@
// Auto-submit on 6 digits for TOTP codes
const codeInput = document.getElementById('code');
let isSubmitting = false;
codeInput.addEventListener('input', function(e) {
if (!backupMode) {
if (!backupMode && !isSubmitting) {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value.length === 6) {
this.form.submit();
if (this.value.length === 6 && this.value.trim() !== '') {
isSubmitting = true;
// Small delay to ensure value is set
setTimeout(() => {
if (this.value.length === 6 && this.value.trim() !== '') {
this.form.submit();
} else {
isSubmitting = false;
}
}, 100);
}
}
});
// Prevent form submission if code is empty
const form = codeInput.closest('form');
form.addEventListener('submit', function(e) {
const code = codeInput.value.trim();
if (!code) {
e.preventDefault();
alert('Please enter a verification code.');
return false;
}
if (!backupMode && (code.length !== 6 || !/^\d{6}$/.test(code))) {
e.preventDefault();
alert('Please enter a valid 6-digit code.');
return false;
}
});
</script>
</body>
</html>