diff --git a/core/cmd/server/cmd/update.go b/core/cmd/server/cmd/update.go index 2fe9f60e1..f925e66cc 100644 --- a/core/cmd/server/cmd/update.go +++ b/core/cmd/server/cmd/update.go @@ -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