fix: 解决数据库用户名显示错误的问题 (#2028)

This commit is contained in:
ssongliu 2023-08-22 16:32:12 +08:00 committed by wanghe-fit2cloud
parent f0e78c4b7c
commit 0eee2d9807
2 changed files with 4 additions and 6 deletions

View file

@ -305,19 +305,18 @@ func (r *Local) SyncDB(version string) ([]SyncDBInfo, error) {
}
}
if len(dataItem.Username) == 0 {
username := loadNameByDB(parts[0], version)
dataItem.Username = loadNameByDB(parts[0], version)
if err := r.CreateUser(CreateInfo{
Name: parts[0],
Format: parts[1],
Version: version,
Username: username,
Username: dataItem.Username,
Password: common.RandStr(16),
Permission: "%",
Timeout: 300,
}, false); err != nil {
global.LOG.Errorf("sync from remote server failed, err: create user failed %v", err)
}
dataItem.Username = parts[0]
dataItem.Permission = "%"
} else {
if isLocal {

View file

@ -316,19 +316,18 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) {
i++
}
if len(dataItem.Username) == 0 {
userName := loadNameByDB(dbName, version)
dataItem.Username = loadNameByDB(dbName, version)
if err := r.CreateUser(CreateInfo{
Name: dbName,
Format: charsetName,
Version: version,
Username: userName,
Username: dataItem.Username,
Password: common.RandStr(16),
Permission: "%",
Timeout: 300,
}, false); err != nil {
return datas, fmt.Errorf("sync db from remote server failed, err: create user failed %v", err)
}
dataItem.Username = dbName
dataItem.Permission = "%"
} else {
if isLocal {