mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: use config value instead of hard coded values
This commit is contained in:
1 parent
ccbc4ff4b0
commit
58f3bf7817
1 file changed
+2
-2
@@ -40,7 +40,7 @@ export async function rateLimitByAccount(
|
||||
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({
|
||||
username,
|
||||
@@ -49,7 +49,7 @@ export async function rateLimitByAccount(
|
||||
time: { $gte: since },
|
||||
})
|
||||
|
||||
if (recentFailedCount >= 5) {
|
||||
if (recentFailedCount >= config.rateLimit.maxFailedAttempts) {
|
||||
logger.warn(
|
||||
`Too many failed login attempts for "${username}" from ${req.ip}`
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user