From 90283ef29c47ed86344ccf3f278d08e9ae748d2c Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Thu, 7 Jul 2022 21:31:43 +0800 Subject: [PATCH] chore: incorrect username retry count --- server/controllers/auth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/controllers/auth.go b/server/controllers/auth.go index 2bd607e2..afb4321b 100644 --- a/server/controllers/auth.go +++ b/server/controllers/auth.go @@ -26,7 +26,7 @@ func Login(c *gin.Context) { ip := c.ClientIP() count, ok := loginCache.Get(ip) if ok && count >= defaultTimes { - common.ErrorStrResp(c, "Too many unsuccessful sign-in attempts have been made using an incorrect password. Try again later.", 403) + common.ErrorStrResp(c, "Too many unsuccessful sign-in attempts have been made using an incorrect username or password. Try again later.", 403) loginCache.Expire(ip, defaultDuration) return } @@ -39,6 +39,7 @@ func Login(c *gin.Context) { user, err := db.GetUserByName(req.Username) if err != nil { common.ErrorResp(c, err, 400) + loginCache.Set(ip, count+1) return } // validate password