diff --git a/auth.go b/auth.go index 8a5e2c4..44a03df 100644 --- a/auth.go +++ b/auth.go @@ -119,18 +119,12 @@ func loginStatus(ip string) (int, int) { } } a.times = kept - remaining := loginMaxAttempts - len(a.times) - if remaining < 0 { - remaining = 0 - } + remaining := max(loginMaxAttempts - len(a.times), 0) retryAfter := 0 if remaining == 0 && len(a.times) > 0 { // Time until the oldest attempt falls out of the window. next := a.times[0].Add(loginWindow).Sub(time.Now()) - retryAfter = int(next.Seconds()) + 1 - if retryAfter < 1 { - retryAfter = 1 - } + retryAfter = max(int(next.Seconds()) + 1, 1) } return remaining, retryAfter }