fix(ratelimit): block on 5th attempt not 6th
This commit is contained in:
@@ -76,8 +76,8 @@ func RateLimitAuth(next http.Handler) http.Handler {
|
|||||||
v.lastSeen = time.Now()
|
v.lastSeen = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If more than 5 attempts within a minute, block
|
// If 5 or more attempts within a minute, block
|
||||||
if exists && v.attempts > 5 {
|
if exists && v.attempts >= 5 {
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
if strings.HasPrefix(r.URL.Path, "/") {
|
if strings.HasPrefix(r.URL.Path, "/") {
|
||||||
http.Redirect(w, r, fmt.Sprintf("%s?error=rate_limited", r.URL.Path), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("%s?error=rate_limited", r.URL.Path), http.StatusFound)
|
||||||
|
|||||||
Reference in New Issue
Block a user