From c7531a942fee1f37fe307fe011de32590b24183f Mon Sep 17 00:00:00 2001 From: fretuks Date: Wed, 29 Oct 2025 15:15:22 +0100 Subject: [PATCH] small fix to frontend --- public/Backend.js | 8 ++++---- public/index.html | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/public/Backend.js b/public/Backend.js index 4a3c573..077a2fc 100644 --- a/public/Backend.js +++ b/public/Backend.js @@ -7,13 +7,13 @@ app.use(express.json()); const users = JSON.parse(fs.readFileSync('TEST_DATA/users.json', 'utf8')); app.post('/login', (req, res) => { - const {username, password} = req.body; + const { username, password } = req.body; const user = users.find(u => u.username === username && u.password === password); + if (user) { - res.status(200); - res.json({ ok: true, message: 'Login erfolgreich' }); + res.status(200).json({ ok: true, message: 'Login erfolgreich' }); } else { - res.status(401).send('Falscher Benutzername oder Passwort'); + res.status(401).json({ ok: false, error: 'Falscher Benutzername oder Passwort' }); } }); diff --git a/public/index.html b/public/index.html index bef588f..27e5040 100644 --- a/public/index.html +++ b/public/index.html @@ -120,9 +120,8 @@ msg.textContent = '✅ Erfolgreich eingeloggt!'; msg.className = 'msg success'; } else { - msg.textContent = '❌ ' + (data.error || 'Login fehlgeschlagen'); - msg.className = 'msg error'; - msg.style.display = 'block'; + msg.textContent = '❌ ' + (data.error || 'Login fehlgeschlagen'); + msg.className = 'msg error'; } } catch (err) { msg.textContent = '⚠️ Netzwerkfehler: ' + err.message;