mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
more housekeeping
This commit is contained in:
@@ -20,6 +20,9 @@ function getClientIp(request) {
|
||||
|
||||
function isRateLimited(ip) {
|
||||
const now = Date.now();
|
||||
for (const [key, rec] of loginAttempts) {
|
||||
if (now - rec.firstAttempt > LOGIN_WINDOW_MS) loginAttempts.delete(key);
|
||||
}
|
||||
const record = loginAttempts.get(ip);
|
||||
if (!record || now - record.firstAttempt > LOGIN_WINDOW_MS) {
|
||||
loginAttempts.set(ip, { count: 1, firstAttempt: now });
|
||||
|
||||
Reference in New Issue
Block a user