Remove unneeded
This commit is contained in:
@@ -26,7 +26,6 @@ app.post('/login', async (req, res) => {
|
|||||||
const ip = req.ip || req.connection.remoteAddress;
|
const ip = req.ip || req.connection.remoteAddress;
|
||||||
const user = users.find(u => u.username === username && u.password === password);
|
const user = users.find(u => u.username === username && u.password === password);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
if (!loginAttempts[username]) {
|
if (!loginAttempts[username]) {
|
||||||
loginAttempts[username] = {
|
loginAttempts[username] = {
|
||||||
count: 0,
|
count: 0,
|
||||||
@@ -36,10 +35,7 @@ app.post('/login', async (req, res) => {
|
|||||||
cooldownUntil: null
|
cooldownUntil: null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = loginAttempts[username];
|
const state = loginAttempts[username];
|
||||||
|
|
||||||
// 🔹 Lockout aktiv?
|
|
||||||
if (state.lockedUntil && now < state.lockedUntil) {
|
if (state.lockedUntil && now < state.lockedUntil) {
|
||||||
const remaining = Math.ceil((state.lockedUntil - now) / 1000);
|
const remaining = Math.ceil((state.lockedUntil - now) / 1000);
|
||||||
logAttempt(username, 'LOCKED', ip, `Noch gesperrt: ${remaining}s`);
|
logAttempt(username, 'LOCKED', ip, `Noch gesperrt: ${remaining}s`);
|
||||||
@@ -48,8 +44,6 @@ app.post('/login', async (req, res) => {
|
|||||||
error: `Benutzer gesperrt. Bitte in ${remaining}s erneut versuchen.`
|
error: `Benutzer gesperrt. Bitte in ${remaining}s erneut versuchen.`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔹 Cooldown aktiv?
|
|
||||||
if (state.cooldownUntil && now < state.cooldownUntil) {
|
if (state.cooldownUntil && now < state.cooldownUntil) {
|
||||||
const remaining = Math.ceil((state.cooldownUntil - now) / 1000);
|
const remaining = Math.ceil((state.cooldownUntil - now) / 1000);
|
||||||
logAttempt(username, 'COOLDOWN', ip, `Wartezeit noch ${remaining}s`);
|
logAttempt(username, 'COOLDOWN', ip, `Wartezeit noch ${remaining}s`);
|
||||||
@@ -59,8 +53,6 @@ app.post('/login', async (req, res) => {
|
|||||||
requiresCaptcha: state.requiresCaptcha
|
requiresCaptcha: state.requiresCaptcha
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔹 Captcha-Prüfung (falls aktiv)
|
|
||||||
if (state.requiresCaptcha) {
|
if (state.requiresCaptcha) {
|
||||||
if (!captcha || typeof captcha !== 'string') {
|
if (!captcha || typeof captcha !== 'string') {
|
||||||
logAttempt(username, 'CAPTCHA_MISSING', ip);
|
logAttempt(username, 'CAPTCHA_MISSING', ip);
|
||||||
@@ -125,7 +117,6 @@ app.post('/login', async (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Einfaches Frontend für Tests
|
|
||||||
app.get('/login', (req, res) => {
|
app.get('/login', (req, res) => {
|
||||||
res.sendFile(__dirname + '/index.html');
|
res.sendFile(__dirname + '/index.html');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user