feat: return bind credentials and reuse sync-bound agents on register (Z28)
Phone/bind-code/ticket responses include rotated client_secret; SelfRegister reuses active sync_bound hosts instead of spawning pending; archive coop opinion and keep a living summary. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -113,6 +113,7 @@ type BindCodeRedeemResp struct {
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
AgentID int64 `json:"agent_id"`
|
||||
ClientID string `json:"client_id,omitempty"`
|
||||
ClientSecret string `json:"client_secret,omitempty"` // Z28:绑定成功回传,便于直接换票
|
||||
ChannelID string `json:"channel_id"`
|
||||
OnlineDBID string `json:"online_db_id"`
|
||||
DatabaseName string `json:"database_name,omitempty"`
|
||||
@@ -158,6 +159,11 @@ func (l *AuthLogic) RedeemBindCode(req BindCodeRedeemReq) (*BindCodeRedeemResp,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Z28:回传可换票凭证
|
||||
secret, err := l.svcCtx.Agents.RotateSecret(l.ctx, updated.TenantID, updated.AgentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("rotate client_secret: %w", err)
|
||||
}
|
||||
_ = l.writeBindAudit("bind_code_redeem", updated.TenantID, updated.AgentID, map[string]any{
|
||||
"code": bc.Code, "channel_id": bc.ChannelID, "online_db_id": online,
|
||||
})
|
||||
@@ -166,11 +172,12 @@ func (l *AuthLogic) RedeemBindCode(req BindCodeRedeemReq) (*BindCodeRedeemResp,
|
||||
TenantID: updated.TenantID,
|
||||
AgentID: updated.AgentID,
|
||||
ClientID: updated.ClientID,
|
||||
ClientSecret: secret,
|
||||
ChannelID: updated.ChannelID,
|
||||
OnlineDBID: updated.OnlineDBID,
|
||||
DatabaseName: updated.DatabaseName,
|
||||
SyncBound: true,
|
||||
Message: "绑定成功",
|
||||
Message: "绑定成功;请保存 client_id/client_secret 用于换票",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -300,6 +307,8 @@ type PhoneConfirmResp struct {
|
||||
OK bool `json:"ok"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
AgentID int64 `json:"agent_id"`
|
||||
ClientID string `json:"client_id,omitempty"`
|
||||
ClientSecret string `json:"client_secret,omitempty"` // Z28:绑定成功回传
|
||||
ChannelID string `json:"channel_id"`
|
||||
OnlineDBID string `json:"online_db_id"`
|
||||
DatabaseName string `json:"database_name,omitempty"`
|
||||
@@ -361,7 +370,7 @@ func (l *AuthLogic) PhoneConfirm(req PhoneConfirmReq) (*PhoneConfirmResp, error)
|
||||
if u.TenantID <= 0 {
|
||||
return nil, fmt.Errorf("该账号尚未加入公司")
|
||||
}
|
||||
updated, _, err := l.bindUserHostSync(u, hostKey, req.Name, req.LocalDBID, "phone-confirm")
|
||||
updated, secret, err := l.bindUserHostSync(u, hostKey, req.Name, req.LocalDBID, "phone-confirm")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -373,11 +382,13 @@ func (l *AuthLogic) PhoneConfirm(req PhoneConfirmReq) (*PhoneConfirmResp, error)
|
||||
OK: true,
|
||||
TenantID: updated.TenantID,
|
||||
AgentID: updated.AgentID,
|
||||
ClientID: updated.ClientID,
|
||||
ClientSecret: secret,
|
||||
ChannelID: updated.ChannelID,
|
||||
OnlineDBID: updated.OnlineDBID,
|
||||
DatabaseName: updated.DatabaseName,
|
||||
SyncBound: true,
|
||||
Message: "绑定成功",
|
||||
Message: "绑定成功;请保存 client_id/client_secret 用于换票",
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user