update pwd change

This commit is contained in:
wjqserver 2025-06-22 17:23:41 +08:00
parent b91daad8ad
commit 47b6f4903f
13 changed files with 572 additions and 90 deletions

View file

@ -17,7 +17,7 @@ func InitAdminUser(username string, password string, cdb *db.ConfigDB) error {
userStatus.SetInitialized(true)
return nil
}
hashedPassword, err := hashPassword(password)
hashedPassword, err := HashPassword(password)
if err != nil {
return fmt.Errorf("failed to hash password: %w", err)
}
@ -30,7 +30,7 @@ func InitAdminUser(username string, password string, cdb *db.ConfigDB) error {
}
// bcrypt加密password串
func hashPassword(password string) (string, error) {
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 11)
if err != nil {
return "", err
@ -69,7 +69,7 @@ func InitFormEnv(cdb *db.ConfigDB) error {
}
// 执行初始化
hashedPassword, err := hashPassword(password)
hashedPassword, err := HashPassword(password)
if err != nil {
return fmt.Errorf("failed to hash password from env: %w", err)
}