From 8d659cc5d7773d0c81b52b3c63a80393e8521655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 8 May 2023 13:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20getLoginSalt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/login.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/login.go b/backend/login.go index 7e87050..53b2b9e 100644 --- a/backend/login.go +++ b/backend/login.go @@ -63,8 +63,11 @@ func getLoginSalt(username string) (*saltinfo, error) { } salt := loginsalts.Get(username) if salt.count != nil { - if atomic.AddUintptr(salt.count, 1) >= maxSaltCount { + x := atomic.AddUintptr(salt.count, 1) + if x == maxSaltCount { time.AfterFunc(time.Minute*2, func() { atomic.StoreUintptr(salt.count, 0) }) + } + if x >= maxSaltCount { return nil, errTooManySalts } if salt.Salt != "" {