fix(api): relax account password validation

This commit is contained in:
david
2026-07-30 10:01:19 +08:00
parent 3f7e3f941b
commit 1d5ac6470c
12 changed files with 83 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"reflect"
"strings"
"unicode/utf8"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/infra"
@@ -16,6 +17,14 @@ import (
"gorm.io/gorm"
)
// AccountPasswordMinLength 是账号密码允许的最低字符数。
const AccountPasswordMinLength = 6
// IsValidAccountPassword 仅校验账号密码的最低字符长度。
func IsValidAccountPassword(password string) bool {
return utf8.RuneCountInString(password) >= AccountPasswordMinLength
}
// PasswordHash creates the shared password representation used by account modules.
func PasswordHash(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)