From a49a878b5f31b5569ac25c4bfab2574037febd5f Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 12 Oct 2026 18:15:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(wechat):=20events=20URL=20=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E4=B8=8D=E5=86=8D=E5=9B=A0=20appid=20=E6=97=A0?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=AE=B0=E5=BD=95=E8=80=8C=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=EF=BC=88=E9=A6=96=E6=AC=A1=E9=85=8D=E7=BD=AE/=E5=85=A8?= =?UTF-8?q?=E7=BD=91=E5=8F=91=E5=B8=83=E6=A3=80=E6=B5=8B=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=EF=BC=8C=E4=BB=8D=E6=8C=89=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=20Token=20=E9=AA=8C=E7=AD=BE=E5=9B=9E=E6=98=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/wechatOpen.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controller/wechatOpen.js b/app/controller/wechatOpen.js index d8d77fe..0e2f2f3 100644 --- a/app/controller/wechatOpen.js +++ b/app/controller/wechatOpen.js @@ -430,7 +430,9 @@ class WechatOpenController extends Controller { /** * 验证事件推送服务器 URL(参考 PHP verifyEventUrl)。 - * 对应授权方须已在 wms_wechat_app 登记;签名使用第三方平台(组件)Token 校验。 + * 签名使用第三方平台(组件)Token 校验(与 /Authorization 的 URL 验证一致)。 + * appid 记录不存在时不阻断验证:首次配置服务器地址、微信全网发布检测等场景下, + * 微信会先发 echostr 验证 URL,此时可能尚无授权记录,仍按组件 Token 验签回显。 * @param {string} appid 授权方 AppID。 * @param {string} signature 微信回传签名。 * @param {string} timestamp 时间戳。 @@ -441,11 +443,10 @@ class WechatOpenController extends Controller { async verifyEventUrl(appid, signature, timestamp, nonce, echostr) { const { ctx, app } = this; - // 对应小程序须已授权登记 + // 对应小程序应已授权登记;未登记仅告警,不阻断 URL 验证 const record = await app.model.WechatApp.findOne({ where: { appid } }); if (!record) { - ctx.logger.error(`[wechatOpen.events] URL 验证失败:appid 未登记 appid=${appid}`); - return 'appid not found'; + ctx.logger.warn(`[wechatOpen.events] URL 验证:appid 尚无授权记录(首次配置或检测场景),仍按组件 Token 验签 appid=${appid}`); } const config = app.config.wechatOpen || {};