chore: incorrect username retry count

refactor/fs
Noah Hsu 2022-07-07 21:31:43 +08:00
parent 156da2b794
commit 90283ef29c
1 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,7 @@ func Login(c *gin.Context) {
ip := c.ClientIP() ip := c.ClientIP()
count, ok := loginCache.Get(ip) count, ok := loginCache.Get(ip)
if ok && count >= defaultTimes { 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) loginCache.Expire(ip, defaultDuration)
return return
} }
@ -39,6 +39,7 @@ func Login(c *gin.Context) {
user, err := db.GetUserByName(req.Username) user, err := db.GetUserByName(req.Username)
if err != nil { if err != nil {
common.ErrorResp(c, err, 400) common.ErrorResp(c, err, 400)
loginCache.Set(ip, count+1)
return return
} }
// validate password // validate password