1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-06 14:10:06 +00:00

chore: quick fix

This commit is contained in:
2023-03-29 22:05:29 +05:00
parent bd3aff9a7b
commit c1c0554de2
2 changed files with 12 additions and 4 deletions

View File

@@ -63,12 +63,12 @@ export class RateLimiter {
// Check if IP or Username + IP is already blocked
if (
resSlowByIP !== null &&
resSlowByIP.consumedPoints >= this.maxWrongAttemptsByIpPerDay
resSlowByIP.consumedPoints > this.maxWrongAttemptsByIpPerDay
) {
return Math.ceil(resSlowByIP.msBeforeNext / 1000)
} else if (
resUsernameAndIP !== null &&
resUsernameAndIP.consumedPoints >= this.maxConsecutiveFailsByUsernameAndIp
resUsernameAndIP.consumedPoints > this.maxConsecutiveFailsByUsernameAndIp
) {
return Math.ceil(resUsernameAndIP.msBeforeNext / 1000)
}
@@ -98,6 +98,10 @@ export class RateLimiter {
if (rlRejected instanceof Error) {
throw rlRejected
} else {
// based upon the implementation of consume method of RateLimiterMongo
// we are sure that rlRejected will contain msBeforeNext
// for further reference,
// see https://github.com/animir/node-rate-limiter-flexible/wiki/Overall-example#login-endpoint-protection
return Math.ceil(rlRejected.msBeforeNext / 1000)
}
}