fix: Z35 禁止用中文昵称作 Postgres 库名,发布时纠正脏数据
绑定 database_name 改为 user_{id};publish 遇非法库名 Sanitize 并回写,避免 EnsureDatabase 400。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -191,10 +191,12 @@ func (l *AuthLogic) bindUserHostSync(u *userstore.User, hostKey, name, localID,
|
||||
return nil, "", fmt.Errorf("host_key 已绑定其它公司")
|
||||
}
|
||||
online := fmt.Sprintf("%s_u%d", dbsync.ResolveOnlineDBID("", ch.ID), u.UserID)
|
||||
dbName := strings.TrimSpace(u.DisplayName)
|
||||
if dbName == "" {
|
||||
dbName = fmt.Sprintf("user_%d", u.UserID)
|
||||
// DisplayName 可中文;Postgres 物理库名必须 [a-z][a-z0-9_]{1,47}(Z35)
|
||||
display := strings.TrimSpace(u.DisplayName)
|
||||
if display == "" {
|
||||
display = fmt.Sprintf("user_%d", u.UserID)
|
||||
}
|
||||
dbName := fmt.Sprintf("user_%d", u.UserID)
|
||||
updated, err := l.svcCtx.Agents.AttachSyncBind(l.ctx, acc.AgentID, u.TenantID, ch.ID, online, dbName, true)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
@@ -214,7 +216,7 @@ func (l *AuthLogic) bindUserHostSync(u *userstore.User, hostKey, name, localID,
|
||||
OnlineDBID: online,
|
||||
ChannelID: ch.ID,
|
||||
DatabaseName: dbName,
|
||||
DisplayName: dbName,
|
||||
DisplayName: display,
|
||||
Note: note,
|
||||
})
|
||||
return updated, secret, nil
|
||||
|
||||
Reference in New Issue
Block a user