This commit is contained in:
KingKDot
2026-06-01 16:37:23 -05:00
parent 421abd178c
commit 7f0a7b1d91
17 changed files with 815 additions and 5 deletions
+20 -1
View File
@@ -1,6 +1,8 @@
const form = document.getElementById("login-form");
const user = document.getElementById("user");
const pass = document.getElementById("pass");
const mfaGroup = document.getElementById("mfa-group");
const mfaCode = document.getElementById("mfa-code");
const errEl = document.getElementById("error");
(async () => {
@@ -218,9 +220,26 @@ form?.addEventListener("submit", async (e) => {
const res = await fetch("/api/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ user: user.value, pass: pass.value }),
body: JSON.stringify({
user: user.value,
pass: pass.value,
mfaCode: mfaCode?.value || "",
}),
});
if (res.status === 202) {
const data = await res.json().catch(() => ({}));
if (data.mfaRequired) {
if (mfaGroup) mfaGroup.style.display = "";
if (mfaCode) {
mfaCode.required = true;
mfaCode.focus();
}
errEl.textContent = "Enter your authenticator code to continue.";
return;
}
}
if (!res.ok) {
const data = await res.json();
throw new Error(data.error || "Invalid credentials");