feat: 密码强度校验/密码过期时间功能
This commit is contained in:
@@ -189,13 +189,19 @@ func (s *SysUserController) Add(c *gin.Context) {
|
||||
c.JSON(400, resp.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
if !regular.ValidPassword(body.Password) {
|
||||
// msg := fmt.Sprintf("新增用户【%s】失败,登录密码至少包含大小写字母、数字、特殊符号,且不少于6位", body.UserName)
|
||||
msg := fmt.Sprintf("New user [%s] failed, the login password contains at least upper and lower case letters, numbers, special symbols, and not less than 6 bits", body.UserName)
|
||||
c.JSON(400, resp.ErrMsg(msg))
|
||||
// if !regular.ValidPassword(body.Password) {
|
||||
// // msg := fmt.Sprintf("新增用户【%s】失败,登录密码至少包含大小写字母、数字、特殊符号,且不少于6位", body.UserName)
|
||||
// msg := fmt.Sprintf("New user [%s] failed, the login password contains at least upper and lower case letters, numbers, special symbols, and not less than 6 bits", body.UserName)
|
||||
// c.JSON(400, resp.ErrMsg(msg))
|
||||
// return
|
||||
// }
|
||||
|
||||
// 检查用户密码策略强度
|
||||
ok, errMsg := s.sysUserService.ValidatePasswordPolicy(body.Password, language)
|
||||
if !ok {
|
||||
c.JSON(200, resp.ErrMsg(errMsg))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查用户登录账号是否唯一
|
||||
uniqueUserName := s.sysUserService.CheckUniqueByUserName(body.UserName, 0)
|
||||
if !uniqueUserName {
|
||||
@@ -431,11 +437,17 @@ func (s *SysUserController) Password(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !regular.ValidPassword(body.Password) {
|
||||
c.JSON(200, resp.ErrMsg("Login password contains at least upper and lower case letters, numbers, special symbols, and not less than 6 digits"))
|
||||
// if !regular.ValidPassword(body.Password) {
|
||||
// c.JSON(200, resp.ErrMsg("Login password contains at least upper and lower case letters, numbers, special symbols, and not less than 6 digits"))
|
||||
// return
|
||||
// }
|
||||
|
||||
// 检查用户密码策略强度
|
||||
ok, errMsg := s.sysUserService.ValidatePasswordPolicy(body.Password, language)
|
||||
if !ok {
|
||||
c.JSON(200, resp.ErrMsg(errMsg))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
userInfo := s.sysUserService.FindById(body.UserId)
|
||||
if userInfo.UserId != body.UserId {
|
||||
|
||||
Reference in New Issue
Block a user