Add honeypot field to login form: instant 24h IP ban on autofill
This commit is contained in:
@@ -653,6 +653,10 @@ async function logAudit(req, action, target) {
|
||||
app.post('/api/auth/login', apiLimiter, async (req, res) => {
|
||||
const rawUsername = typeof req.body?.username === 'string' ? req.body.username.trim().toLowerCase() : '';
|
||||
const password = String(req.body?.password || '');
|
||||
if (typeof req.body?.website === 'string' && req.body.website) {
|
||||
await recordFailure(req, 'honeypot', 1, BAN_TTL_MS);
|
||||
return res.status(401).json({ error: 'Неверный логин или пароль' });
|
||||
}
|
||||
if (!rawUsername || rawUsername.length > 100 || !password) {
|
||||
return res.status(401).json({ error: 'Неверный логин или пароль' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user