From 24a4eee4a661af94668f54ce6b4f8ea9762e0aa2 Mon Sep 17 00:00:00 2001 From: Jan Meinl Date: Wed, 19 Aug 2026 16:13:28 +0200 Subject: [PATCH] Simplify loginStatus using max() builtin --- auth.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 }