megacommit

This commit is contained in:
2025-10-11 01:52:21 +01:00
parent f6bd540c99
commit 6092d1d7b4
690 changed files with 91734 additions and 303 deletions
+69 -5
View File
@@ -9,7 +9,7 @@
<body>
<div class="signup-container">
<div class="signup-header">
<div class="logo">DC</div>
<img src="/static/favicon.ico" class="logo"/>
<h1>2FA Setup</h1>
</div>
@@ -23,6 +23,7 @@
<div class="form-group">
<input
type="text"
id="mfa_code"
inputmode="numeric"
pattern="[0-9]*"
maxlength="6"
@@ -38,10 +39,73 @@
</div>
<script>
fetch('/api/totp.jpg')
.then(response => response.json())
.then(data => {
document.getElementById('qr-code').src = data.qr_code;
const form = {
code: document.getElementById("mfa_code"),
};
submitButton.addEventListener("click", async function () {
submitButton.disabled = true;
submitButton.innerHTML =
'<span class="loading-spinner"></span>Creating Account...';
// Prepare data
const formData = {
code: form.code.value.trim(),
};
try {
// Replace with your actual backend endpoint
const response = await fetch(
"/api/totp",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formData),
},
);
if (response.ok) {
// Show success message
successMessage.classList.add("show");
submitButton.innerHTML = "2FA Enabled";
// Optional: Redirect after success
setTimeout(() => {
window.location.href = '/chat';
// console.log("Redirecting to chat...");
}, 2000);
} else {
const error = await response.text();
throw new Error(error || "Login failed");
}
} catch (error) {
console.error("Login error:", error);
alert(
error.message ||
"Failed to login. Please try again.",
);
submitButton.disabled = false;
submitButton.innerHTML = "Login";
}
});
fetch('/api/totp.jpg')
.then(response => response.json())
.then(data => {
document.getElementById('qr-code').src = data.qr_code;
});
// Allow Enter key to submit
Object.values(form).forEach((input) => {
if (input.tagName === "INPUT") {
input.addEventListener("keypress", function (e) {
if (e.key === "Enter") {
submitButton.click();
}
});
}
});
</script>
</body>