fix(weixin): 面板空token保存微信iLink放行——为扫码登录先建账号
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

adminSaveChannelConfig 的 len(cfg)==0 校验要求至少 token/baseUrl/address, 但微信扫码登录
需先建空token账号(再扫码回填 token/bot_id/owner_id)。对 weixin-ilink 豁免该校验,允许空配置
账号保存; 其余平台保持必填。PUT 空token 保存已验证 201。build/test 全绿, 已部署.
This commit is contained in:
Aska committed 2026-09-07 20:58:48 +08:00
1 parent e037fab7d0
commit abb137cfe2
1 file changed
+5 -1
@@ -96,7 +96,11 @@ func (s *Server) adminSaveChannelConfig(w http.ResponseWriter, r *http.Request)
return
}
cfg := channelConfigFromRequest(req)
if len(cfg) == 0 {
// weixin-ilink may be saved with an empty config: the panel creates the account
// first, then the user scans the QR (get_bot_qrcode) which fills bot_token/bot_id/
// owner_id via login-status (design/08 §4). Requiring a token here would block that
// flow, so exempt it from the "at least one field" gate.
if len(cfg) == 0 && platform != "weixin-ilink" {
s.auditClaims(r, "channel.save", "error")
writeError(w, apperr.Wrap(apperr.ErrBadRequest, "bad_request", "至少提供 token/baseUrl/address 等配置字段"))
return