feat: 密码不允许使用最近修改的密码功能

This commit is contained in:
TsMask
2025-03-31 18:31:25 +08:00
parent 15baf77ad3
commit 46b66cda5b
5 changed files with 194 additions and 19 deletions

View File

@@ -237,6 +237,13 @@ func (s *SysProfileController) PasswordUpdate(c *gin.Context) {
return
}
// 检查密码是否与历史密码一致
err = s.sysUserService.ValidatePasswordNotAllowedHistory(userInfo.UserId, body.NewPassword)
if err != nil {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
return
}
// 修改新密码
userInfo.Password = body.NewPassword
userInfo.UpdateBy = userInfo.UserName
@@ -296,6 +303,13 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
return
}
// 检查密码是否与历史密码一致
err = s.sysUserService.ValidatePasswordNotAllowedHistory(userInfo.UserId, body.Password)
if err != nil {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
return
}
userInfo.Password = body.Password
userInfo.UpdateBy = reqctx.LoginUserToUserName(c)
rows := s.sysUserService.Update(userInfo)