feature:暗夜模式兼容调整,初始化需要手动写入初始密码。

This commit is contained in:
pixelmaxQM
2024-05-16 21:55:32 +08:00
parent e8128250f4
commit 3c486d9117
5 changed files with 20 additions and 11 deletions

View File

@@ -7,13 +7,14 @@ import (
)
type InitDB struct {
DBType string `json:"dbType"` // 数据库类型
Host string `json:"host"` // 服务器地址
Port string `json:"port"` // 数据库连接端口
UserName string `json:"userName"` // 数据库用户名
Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库
DBPath string `json:"dbPath"` // sqlite数据库文件路径
AdminPassword string `json:"adminPassword" binding:"required"`
DBType string `json:"dbType"` // 数据库类型
Host string `json:"host"` // 服务器地址
Port string `json:"port"` // 数据库连接端口
UserName string `json:"userName"` // 数据库用户名
Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库名
DBPath string `json:"dbPath"` // sqlite数据库文件路径
}
// MysqlEmptyDsn msyql 空数据库 建库链接

View File

@@ -89,6 +89,7 @@ type InitDBService struct{}
// InitDB 创建数据库并初始化 总入口
func (initDBService *InitDBService) InitDB(conf request.InitDB) (err error) {
ctx := context.TODO()
ctx = context.WithValue(ctx, "adminPassword", conf.AdminPassword)
if len(initializers) == 0 {
return errors.New("无可用初始化过程,请检查初始化是否已执行完成")
}

View File

@@ -44,8 +44,15 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er
if !ok {
return ctx, system.ErrMissingDBContext
}
password := utils.BcryptHash("6447985")
adminPassword := utils.BcryptHash("123456")
ap := ctx.Value("adminPassword")
apStr, ok := ap.(string)
if !ok {
apStr = "123456"
}
password := utils.BcryptHash(apStr)
adminPassword := utils.BcryptHash(apStr)
entities := []sysModel.SysUser{
{