From e4d421c782a181f421e2987f75b4610845e3ef55 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Wed, 24 Jun 2026 22:47:13 +0900 Subject: Harden web UI security --- src/ollama_web/static/login.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/ollama_web/static/login.js (limited to 'src/ollama_web/static/login.js') 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 : "/"); +}); -- cgit v1.2.3