summaryrefslogtreecommitdiff
path: root/src/ollama_web/static/login.js
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-06-24 22:47:13 +0900
committertanaka takashi <isazaka@gmail.com>2026-06-24 22:47:13 +0900
commite4d421c782a181f421e2987f75b4610845e3ef55 (patch)
treee61b848b32dc046977751346d4346c4debc7c4f8 /src/ollama_web/static/login.js
parenta1d744387659f7fe29559017ae03dc76e8532bb1 (diff)
Harden web UI security
Diffstat (limited to 'src/ollama_web/static/login.js')
-rw-r--r--src/ollama_web/static/login.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ollama_web/static/login.js b/src/ollama_web/static/login.js
new file mode 100644
index 0000000..648e219
--- /dev/null
+++ b/src/ollama_web/static/login.js
@@ -0,0 +1,21 @@
+"use strict";
+
+const form = document.getElementById("login-form");
+const pinInput = document.getElementById("pin-input");
+const errorEl = document.getElementById("login-error");
+
+form.addEventListener("submit", async (event) => {
+ event.preventDefault();
+ errorEl.textContent = "";
+ const res = await fetch("/api/auth/login", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ pin: pinInput.value }),
+ });
+ if (!res.ok) {
+ errorEl.textContent = "PINが違います";
+ return;
+ }
+ const next = new URLSearchParams(window.location.search).get("next") || "/";
+ window.location.assign(next.startsWith("/") ? next : "/");
+});