fix: 增加密码策略最小长度验证

This commit is contained in:
TsMask
2025-04-03 17:55:53 +08:00
parent afbb1e6ef4
commit 704ca75059

View File

@@ -287,6 +287,11 @@ func (s SysUser) ValidatePasswordPolicy(password string, errLang string) (bool,
"uppercase": policy.Uppercase, "uppercase": policy.Uppercase,
"lowercase": policy.Lowercase, "lowercase": policy.Lowercase,
}) })
if len(password) < policy.MinLength {
return false, errMsg
}
specialChars := len(regexp.MustCompile(`[!@#$%^&*(),.?":{}|<>]`).FindAllString(password, -1)) specialChars := len(regexp.MustCompile(`[!@#$%^&*(),.?":{}|<>]`).FindAllString(password, -1))
if specialChars < policy.SpecialChars { if specialChars < policy.SpecialChars {
return false, errMsg return false, errMsg