Add authentication flow, client UI, and dependencies

This commit is contained in:
2025-09-24 10:07:49 +02:00
parent 21c35d7e41
commit 3217ed5871
7 changed files with 95 additions and 14 deletions
+14 -10
View File
@@ -1,22 +1,26 @@
const express = require('express');
const express = require('express');
const fs = require('fs');
const app = express();
const port = 3000;
app.use(express.json());
const users = JSON.parse(fs.readFileSync('users.json', 'utf8'));
const users = JSON.parse(fs.readFileSync('C:/Users/frederik/WebstormProjects/BruteForce/TEST_DATA/users.json', 'utf8'));
app.post('/login', (req, res) => {
const { username, password } = req.body;
const user = users.find(u => u.username === username && u.password === password);
const {username, password} = req.body;
const user = users.find(u => u.username === username && u.password === password);
if (user) {
res.send('Login erfolgreich');
} else {
res.status(401).send('Falscher Benutzername oder Passwort');
}
if (user) {
res.send('Login erfolgreich');
} else {
res.status(401).send('Falscher Benutzername oder Passwort');
}
});
app.get('/login', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
app.listen(port, () => {
console.log(`läuft http://localhost:${port}`);
console.log(`läuft http://localhost:${port}`);
});