From 23ca1c12568973bb979129d7581df96fc4101ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=9C=9D=E4=BC=9F?= <2211960668@qq.com> Date: Wed, 22 Mar 2023 10:47:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?commoni18=E5=A2=9E=E5=8A=A0detail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/locales/Common/locales/zh_CN.json | 3 ++- lib/pages/token/me/web.js | 18 +++++++++++------- src/locales/Common/locales/zh_CN.json | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/locales/Common/locales/zh_CN.json b/lib/locales/Common/locales/zh_CN.json index 1472d4f33..fc2a74a6e 100644 --- a/lib/locales/Common/locales/zh_CN.json +++ b/lib/locales/Common/locales/zh_CN.json @@ -14,7 +14,8 @@ "cancel": "取消", "grant": "授权", "revoke": "回收", - "tip": "提示" + "tip": "提示", + "detail": "详情" }, "reset": "重置", "select": "查询", diff --git a/lib/pages/token/me/web.js b/lib/pages/token/me/web.js index 2ae3d799d..002fa6393 100644 --- a/lib/pages/token/me/web.js +++ b/lib/pages/token/me/web.js @@ -25,12 +25,16 @@ function Render(props) { return [2 /*return*/]; } }); - }); } }, { children: t('common:action.confirm') })) }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u6635\u79F0", value: nickname, onChange: function (e) { return updateItem({ user: { - id: (0, uuid_1.generateNewId)(), - action: 'update', - data: { - nickname: e.target.value - } - } }, tokenId); } }) }))] }))); + }); } }, { children: t('common:action.confirm') })) }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u6635\u79F0", value: nickname, onChange: function (e) { + return updateItem({ + user: { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + nickname: e.target.value, + }, + }, + }, tokenId); + } }) }))] }))); } exports.default = Render; diff --git a/src/locales/Common/locales/zh_CN.json b/src/locales/Common/locales/zh_CN.json index ec85e33dd..1798b73da 100644 --- a/src/locales/Common/locales/zh_CN.json +++ b/src/locales/Common/locales/zh_CN.json @@ -14,7 +14,8 @@ "cancel": "取消", "grant": "授权", "revoke": "回收", - "tip": "提示" + "tip": "提示", + "detail": "详情" }, "reset": "重置", "select": "查询", From 0725963f6a481f438e9fe0bf0d95561d790ae4e3 Mon Sep 17 00:00:00 2001 From: wenjiarui Date: Wed, 22 Mar 2023 12:00:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BD=93userENtityGrant=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=8E=A8=E9=80=81=E8=BF=87=E6=9C=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/aspects/token.js | 33 +++++++++------------------ lib/endpoints/wechat.js | 48 +++++++++++++++++++++++++++------------ lib/pages/token/me/web.js | 18 +++++++++------ src/aspects/token.ts | 12 +++++----- src/endpoints/wechat.ts | 47 ++++++++++++++++++++++++++------------ 5 files changed, 93 insertions(+), 65 deletions(-) diff --git a/lib/aspects/token.js b/lib/aspects/token.js index a9167d292..44d2bdf77 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -1125,9 +1125,9 @@ function syncUserInfoWechatMp(_a, context) { var _b, _c, _d; var nickname = _a.nickname, avatarUrl = _a.avatarUrl, encryptedData = _a.encryptedData, iv = _a.iv, signature = _a.signature; return tslib_1.__awaiter(this, void 0, void 0, function () { - var userId, application, config, _e, _f, sessionKey, user; - return tslib_1.__generator(this, function (_g) { - switch (_g.label) { + var userId, application, config, _e, _f, sessionKey, user, _g, type, config2, _h, appId, appSecret, wechatInstance, result; + return tslib_1.__generator(this, function (_j) { + switch (_j.label) { case 0: userId = context.getToken().userId; application = context.getApplication(); @@ -1169,28 +1169,17 @@ function syncUserInfoWechatMp(_a, context) { dontCollect: true, })]; case 1: - _e = tslib_1.__read.apply(void 0, [_g.sent(), 1]), _f = _e[0], sessionKey = _f.sessionKey, user = _f.user; - // console.log(avatarUrl); - // const { type, config } = application; - // assert(type === 'wechatMp' || config.type === 'wechatMp'); - // const config2 = config as WechatMpConfig; - // const { appId, appSecret } = config2; - // const wechatInstance = WechatSDK.getInstance(appId, 'wechatMp', appSecret); - // const result = wechatInstance.decryptData(sessionKey as string, encryptedData, iv, signature); + _e = tslib_1.__read.apply(void 0, [_j.sent(), 1]), _f = _e[0], sessionKey = _f.sessionKey, user = _f.user; + _g = application, type = _g.type, config2 = _g.config; + (0, assert_1.assert)(type === 'wechatMp' || config2.type === 'wechatMp'); + _h = config2, appId = _h.appId, appSecret = _h.appSecret; + wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId, 'wechatMp', appSecret); + result = wechatInstance.decryptData(sessionKey, encryptedData, iv, signature); // 实测发现解密出来的和userInfo完全一致…… - // console.log(result); + console.log(result); return [4 /*yield*/, setUserInfoFromWechat(user, { nickname: nickname, avatar: avatarUrl }, context)]; case 2: - // console.log(avatarUrl); - // const { type, config } = application; - // assert(type === 'wechatMp' || config.type === 'wechatMp'); - // const config2 = config as WechatMpConfig; - // const { appId, appSecret } = config2; - // const wechatInstance = WechatSDK.getInstance(appId, 'wechatMp', appSecret); - // const result = wechatInstance.decryptData(sessionKey as string, encryptedData, iv, signature); - // 实测发现解密出来的和userInfo完全一致…… - // console.log(result); - _g.sent(); + _j.sent(); return [2 /*return*/]; } }); diff --git a/lib/endpoints/wechat.js b/lib/endpoints/wechat.js index 06b32733c..26da9ea71 100644 --- a/lib/endpoints/wechat.js +++ b/lib/endpoints/wechat.js @@ -293,12 +293,21 @@ function setUserSubscribed(openId, eventKey, context) { time: "".concat(Date.now()), }); content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C\u8BF7\u70B9\u51FB\u9886\u53D6"); - (0, assert_1.default)(!expired_1); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 - wechatInstance.sendServeMessage({ - openId: openId, - type: 'text', - content: content, - }); + // assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 + if (!expired_1) { + wechatInstance.sendServeMessage({ + openId: openId, + type: 'text', + content: content, + }); + } + else { + wechatInstance.sendServeMessage({ + openId: openId, + type: 'text', + content: '您好,您扫描的二维码已经过期,请联系管理员重新获取', + }); + } return [3 /*break*/, 9]; case 7: return [4 /*yield*/, context.select('domain', { data: { @@ -329,15 +338,24 @@ function setUserSubscribed(openId, eventKey, context) { scene: sceneStr, time: "".concat(Date.now()), }); - (0, assert_1.default)(!expired_1); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 - wechatInstance.sendServeMessage({ - openId: openId, - type: 'news', - url: url, - title: "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743"), - description: '请接受', - picurl: 'http://img95.699pic.com/element/40018/2473.png_860.png', - }); + // assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 + if (!expired_1) { + wechatInstance.sendServeMessage({ + openId: openId, + type: 'news', + url: url, + title: "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743"), + description: '请接受', + picurl: 'http://img95.699pic.com/element/40018/2473.png_860.png', + }); + } + else { + wechatInstance.sendServeMessage({ + openId: openId, + type: 'text', + content: '您好,您扫描的二维码已经过期,请联系管理员重新获取', + }); + } _k.label = 9; case 9: return [3 /*break*/, 11]; case 10: diff --git a/lib/pages/token/me/web.js b/lib/pages/token/me/web.js index 2ae3d799d..002fa6393 100644 --- a/lib/pages/token/me/web.js +++ b/lib/pages/token/me/web.js @@ -25,12 +25,16 @@ function Render(props) { return [2 /*return*/]; } }); - }); } }, { children: t('common:action.confirm') })) }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u6635\u79F0", value: nickname, onChange: function (e) { return updateItem({ user: { - id: (0, uuid_1.generateNewId)(), - action: 'update', - data: { - nickname: e.target.value - } - } }, tokenId); } }) }))] }))); + }); } }, { children: t('common:action.confirm') })) }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u6635\u79F0", value: nickname, onChange: function (e) { + return updateItem({ + user: { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + nickname: e.target.value, + }, + }, + }, tokenId); + } }) }))] }))); } exports.default = Render; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index 425d842ae..833508f5e 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -950,15 +950,15 @@ export async function syncUserInfoWechatMp; - // assert(type === 'wechatMp' || config.type === 'wechatMp'); + assert(type === 'wechatMp' || config2!.type === 'wechatMp'); // const config2 = config as WechatMpConfig; - // const { appId, appSecret } = config2; - // const wechatInstance = WechatSDK.getInstance(appId, 'wechatMp', appSecret); - // const result = wechatInstance.decryptData(sessionKey as string, encryptedData, iv, signature); + const { appId, appSecret } = config2 as WechatMpConfig; + const wechatInstance = WechatSDK.getInstance(appId, 'wechatMp', appSecret); + const result = wechatInstance.decryptData(sessionKey as string, encryptedData, iv, signature); // 实测发现解密出来的和userInfo完全一致…… - // console.log(result); + console.log(result); await setUserInfoFromWechat(user!, { nickname, avatar: avatarUrl }, context); } diff --git a/src/endpoints/wechat.ts b/src/endpoints/wechat.ts index 58ee2c518..34b0b0109 100644 --- a/src/endpoints/wechat.ts +++ b/src/endpoints/wechat.ts @@ -303,12 +303,21 @@ async function setUserSubscribed(openId: string, eventKey: string, context: BRC) // 先试着发文字链接 const content = `${name}为您创建了一个授权,请点击领取`; - assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 - wechatInstance.sendServeMessage({ - openId, - type: 'text', - content, - }); + // assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 + if (!expired) { + wechatInstance.sendServeMessage({ + openId, + type: 'text', + content, + }); + } else { + wechatInstance.sendServeMessage({ + openId, + type: 'text', + content: '您好,您扫描的二维码已经过期,请联系管理员重新获取', + }); + } + } else { // 推domain上的scan/code链接 @@ -341,15 +350,23 @@ async function setUserSubscribed(openId: string, eventKey: string, context: BRC) time: `${Date.now()}`, }); - assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 - wechatInstance.sendServeMessage({ - openId, - type: 'news', - url, - title: `${name}为您创建了一个授权`, - description: '请接受', - picurl: 'http://img95.699pic.com/element/40018/2473.png_860.png', - }); + // assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 + if (!expired) { + wechatInstance.sendServeMessage({ + openId, + type: 'news', + url, + title: `${name}为您创建了一个授权`, + description: '请接受', + picurl: 'http://img95.699pic.com/element/40018/2473.png_860.png', + }); + } else { + wechatInstance.sendServeMessage({ + openId, + type: 'text', + content: '您好,您扫描的二维码已经过期,请联系管理员重新获取', + }); + } } } }