From a6d9a992416e6257c9626f485d002b1dba753f70 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 10 Jul 2025 09:35:25 +0200 Subject: [PATCH] Adding login form and handler --- client/login.html | 2 +- client/login.js | 2 +- controller.go | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/login.html b/client/login.html index cc41333..30f0d2d 100644 --- a/client/login.html +++ b/client/login.html @@ -12,7 +12,7 @@ - + diff --git a/client/login.js b/client/login.js index 7e457bb..242d5fa 100644 --- a/client/login.js +++ b/client/login.js @@ -2,6 +2,6 @@ function login() { const usernameInput = document.getElementById('username'); const passwordInput = document.getElementById('password'); - const token = btoa(`${usernameInput.textContent}:${passwordInput.textContent}`); + const token = btoa(`${usernameInput.value}:${passwordInput.value}`); document.cookie = `token=${String(token)}; path=/`; } \ No newline at end of file diff --git a/controller.go b/controller.go index 5ba4b8a..52957d3 100644 --- a/controller.go +++ b/controller.go @@ -158,6 +158,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case r.Method == "GET" && r.URL.Path == "/rsvps_list": getStaticFile("./client/rsvps_list.html", "text/html", w) + case r.Method == "GET" && r.URL.Path == "/login": + getStaticFile("./client/login.html", "text/html", w) + case r.Method == "GET" && r.URL.Path == "/index.js": getStaticFile("./client/index.js", "text/javascript", w) @@ -167,6 +170,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case r.Method == "GET" && r.URL.Path == "/rsvps_list.js": getStaticFile("./client/rsvps_list.js", "text/javascript", w) + case r.Method == "GET" && r.URL.Path == "/login.js": + getStaticFile("./client/login.js", "text/javascript", w) + case r.Method == "GET" && r.URL.Path == "/style.css": getStaticFile("./client/style.css", "text/css", w)