feat: rehash password with a unique salt for each user

This commit is contained in:
Andy Hsu
2023-08-07 15:46:19 +08:00
parent ff5cf3f4fa
commit 1c00d64952
5 changed files with 52 additions and 33 deletions

View File

@ -33,7 +33,7 @@ func Login(c *gin.Context) {
common.ErrorResp(c, err, 400)
return
}
req.Password = model.HashPwd(req.Password)
req.Password = model.StaticHash(req.Password)
loginHash(c, &req)
}
@ -64,7 +64,7 @@ func loginHash(c *gin.Context, req *LoginReq) {
return
}
// validate password hash
if err := user.ValidatePwdHash(req.Password); err != nil {
if err := user.ValidatePwdStaticHash(req.Password); err != nil {
common.ErrorResp(c, err, 400)
loginCache.Set(ip, count+1)
return