fix: use config value instead of hard coded values

This commit is contained in:
Justin Lin committed 2025-04-27 16:41:19 +08:00
1 parent ccbc4ff4b0
commit 58f3bf7817
1 file changed
+2 -2
+2 -2
View File
@@ -40,7 +40,7 @@ export async function rateLimitByAccount(
return next() return next()
} }
const since = new Date(Date.now() - 10 * 60 * 1000) const since = new Date(Date.now() - config.rateLimit.lockoutTime)
const recentFailedCount = await LoginAttempt.countDocuments({ const recentFailedCount = await LoginAttempt.countDocuments({
username, username,
@@ -49,7 +49,7 @@ export async function rateLimitByAccount(
time: { $gte: since }, time: { $gte: since },
}) })
if (recentFailedCount >= 5) { if (recentFailedCount >= config.rateLimit.maxFailedAttempts) {
logger.warn( logger.warn(
`Too many failed login attempts for "${username}" from ${req.ip}` `Too many failed login attempts for "${username}" from ${req.ip}`
) )