Skip to content

Commit

Permalink
chore: incorrect username retry count
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 7, 2022
1 parent 156da2b commit 90283ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 90283ef

Please sign in to comment.