Files
jiggablend/web/static/login.js
Justin Harms 2deb47e5ad Refactor web build process and update documentation
- Removed Node.js build artifacts from .gitignore and adjusted Makefile to reflect changes in web UI build process, now using server-rendered Go templates instead of React.
- Updated README to clarify the new web UI architecture and output formats, emphasizing the removal of the Node.js build step.
- Added a command to set the number of frames per render task in manager configuration, enhancing user control over rendering settings.
- Improved Gitea workflow by removing unnecessary npm install step, streamlining the CI process.
2026-03-12 19:44:40 -05:00

66 lines
1.7 KiB
JavaScript

(function () {
const loginForm = document.getElementById("login-form");
const registerForm = document.getElementById("register-form");
const errorEl = document.getElementById("auth-error");
function setError(msg) {
if (!errorEl) return;
if (!msg) {
errorEl.classList.add("hidden");
errorEl.textContent = "";
return;
}
errorEl.textContent = msg;
errorEl.classList.remove("hidden");
}
async function postJSON(url, payload) {
const res = await fetch(url, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const body = await res.json().catch(() => ({}));
if (!res.ok) {
throw new Error(body.error || "Request failed");
}
return body;
}
if (loginForm) {
loginForm.addEventListener("submit", async (e) => {
e.preventDefault();
setError("");
const fd = new FormData(loginForm);
try {
await postJSON("/api/auth/local/login", {
username: fd.get("username"),
password: fd.get("password"),
});
window.location.href = "/jobs";
} catch (err) {
setError(err.message);
}
});
}
if (registerForm) {
registerForm.addEventListener("submit", async (e) => {
e.preventDefault();
setError("");
const fd = new FormData(registerForm);
try {
await postJSON("/api/auth/local/register", {
name: fd.get("name"),
email: fd.get("email"),
password: fd.get("password"),
});
window.location.href = "/jobs";
} catch (err) {
setError(err.message);
}
});
}
})();