diff --git a/public/dashboard.html b/public/dashboard.html index 9770940..0ba2a4a 100644 --- a/public/dashboard.html +++ b/public/dashboard.html @@ -2,280 +2,29 @@ - - Dashboard - Elemente Auswahl - + Dashboard + -
-

✅ Login erfolgreich!

- -
- -
-
-

Willkommen!

-

Nutze die Filter rechts, um deine Auswahl einzugrenzen.

-
- -
-

Filter

- -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-

Lade Elemente...

-
-
+
+

Dashboard

+

Login erfolgreich 🎉

+
+ \ No newline at end of file diff --git a/public/login.js b/public/login.js index e69de29..f13b34d 100644 --- a/public/login.js +++ b/public/login.js @@ -0,0 +1,35 @@ +const form = document.getElementById("loginForm") +const errorMessage = document.getElementById("errorMessage") + +form.addEventListener("submit", async (event) => { + event.preventDefault() + + const username = document.getElementById("username").value + const password = document.getElementById("password").value + + try { + const response = await fetch("/auth/login", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ username, password }) + }) + + const data = await response.json() + + if (!response.ok) { + errorMessage.textContent = data.message + return + } + + // Token speichern + localStorage.setItem("token", data.token) + + // Weiterleiten + window.location.href = "dashboard.html" + + } catch (err) { + errorMessage.textContent = "Server nicht erreichbar" + } +}) \ No newline at end of file