mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-14 08:05:48 +00:00
fix(cmd): align simple password validation with frontend (#14384)
This commit is contained in:
@@ -272,13 +272,9 @@ func password() {
|
||||
return
|
||||
}
|
||||
complexSetting := getSettingByKey(db, "ComplexityVerification")
|
||||
switch validatePassword(newPassword, complexSetting) {
|
||||
case passwordTooWeak:
|
||||
if complexSetting == constant.StatusEnable && !isValidPassword(newPassword) {
|
||||
fmt.Println("\n" + i18n.GetMsgByKeyForCmd("UpdatePasswordFormat"))
|
||||
return
|
||||
case passwordTooShort:
|
||||
fmt.Println(i18n.GetMsgByKeyForCmd("UpdatePasswordLen"))
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Print("\n" + i18n.GetMsgByKeyForCmd("UpdatePasswordRe"))
|
||||
@@ -376,24 +372,6 @@ func port() {
|
||||
}
|
||||
}
|
||||
|
||||
type passwordValidation int
|
||||
|
||||
const (
|
||||
passwordValid passwordValidation = iota
|
||||
passwordTooShort
|
||||
passwordTooWeak
|
||||
)
|
||||
|
||||
func validatePassword(password, complexitySetting string) passwordValidation {
|
||||
if complexitySetting == constant.StatusEnable && !isValidPassword(password) {
|
||||
return passwordTooWeak
|
||||
}
|
||||
if len(password) < 6 {
|
||||
return passwordTooShort
|
||||
}
|
||||
return passwordValid
|
||||
}
|
||||
|
||||
func isValidPassword(password string) bool {
|
||||
numCount := 0
|
||||
alphaCount := 0
|
||||
|
||||
Reference in New Issue
Block a user