fix: 增加密码策略最小长度验证
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user