@tachybase/plugin-auth-wechat 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.
|
|
4
|
-
"@ant-design/icons": "
|
|
3
|
+
"@tachybase/client": "1.6.1",
|
|
4
|
+
"@ant-design/icons": "6.1.0",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/module-auth": "1.
|
|
7
|
-
"@tachybase/schema": "1.
|
|
6
|
+
"@tachybase/module-auth": "1.6.1",
|
|
7
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
8
8
|
"react-router-dom": "6.28.1",
|
|
9
9
|
"react-i18next": "16.2.1",
|
|
10
|
-
"@tego/server": "1.
|
|
10
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
11
11
|
"dayjs": "1.11.13"
|
|
12
12
|
};
|
|
@@ -26,7 +26,7 @@ const getAuthCfg = async (ctx, next) => {
|
|
|
26
26
|
const { redirect, bind } = ctx.action.params.values;
|
|
27
27
|
if (bind) {
|
|
28
28
|
const { authenticator } = ctx.action.params.values;
|
|
29
|
-
const app = ctx.
|
|
29
|
+
const app = ctx.tego;
|
|
30
30
|
const options = await app.authManager.getOptions(authenticator);
|
|
31
31
|
ctx.body = getBindAuthCfg(ctx, redirect, (_a = options == null ? void 0 : options.wechatAuth) == null ? void 0 : _a.AppID);
|
|
32
32
|
} else {
|
|
@@ -40,7 +40,7 @@ const getBindAuthCfg = (ctx, redirect, appID) => {
|
|
|
40
40
|
if (!userId) {
|
|
41
41
|
ctx.throw(400, "Bind user failed: no user found");
|
|
42
42
|
}
|
|
43
|
-
const app = ctx.
|
|
43
|
+
const app = ctx.tego.name;
|
|
44
44
|
const referer = ctx.req.headers["referer"];
|
|
45
45
|
let redirectUrl;
|
|
46
46
|
if (referer) {
|
|
@@ -50,7 +50,7 @@ const getBindAuthCfg = (ctx, redirect, appID) => {
|
|
|
50
50
|
redirectUrl = `${ctx.protocol}://${ctx.host}${process.env.API_BASE_PATH}wechatAuth:redirect`;
|
|
51
51
|
}
|
|
52
52
|
let state = `redirect=${redirect}&app=${app}&name=${ctx.headers["x-authenticator"]}`;
|
|
53
|
-
const token = ctx.
|
|
53
|
+
const token = ctx.tego.authManager.jwt.sign({ userId: ctx.auth.user.id }, { expiresIn: `${import_constants.AUTH_TIMEOUT_MINUTE}m` });
|
|
54
54
|
state += `&bindToken=${token}`;
|
|
55
55
|
return {
|
|
56
56
|
appId: appID,
|
|
@@ -47,18 +47,19 @@ const redirect = async (ctx, next) => {
|
|
|
47
47
|
prefix += `apps/${appName}`;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
const auth = await ctx.
|
|
50
|
+
const auth = await ctx.tego.authManager.get(authenticator, ctx);
|
|
51
51
|
if (prefix.endsWith("/")) {
|
|
52
52
|
prefix = prefix.slice(0, -1);
|
|
53
53
|
}
|
|
54
54
|
const bindToken = search.get("bindToken");
|
|
55
55
|
if (bindToken) {
|
|
56
56
|
try {
|
|
57
|
-
const user = await ctx.
|
|
57
|
+
const user = await ctx.tego.authManager.jwt.decode(bindToken);
|
|
58
58
|
if (!user) {
|
|
59
59
|
ctx.throw(401, "Bind user failed: no user found");
|
|
60
60
|
}
|
|
61
|
-
await
|
|
61
|
+
const wechatAuth = await ctx.tego.authManager.get(authenticator, ctx);
|
|
62
|
+
await wechatAuth.bindUser(user.userId);
|
|
62
63
|
ctx.redirect(`${prefix}${redirect2}`);
|
|
63
64
|
} catch (error) {
|
|
64
65
|
ctx.logger.error("WeChat auth error", { error });
|
|
File without changes
|
|
@@ -118,7 +118,7 @@ class WeChatAuth extends import_server.BaseAuth {
|
|
|
118
118
|
async getAuthCfg(redirect) {
|
|
119
119
|
var _a, _b;
|
|
120
120
|
const appID = (_b = (_a = this.options) == null ? void 0 : _a.wechatAuth) == null ? void 0 : _b.AppID;
|
|
121
|
-
const app = this.ctx.
|
|
121
|
+
const app = this.ctx.tego.name;
|
|
122
122
|
const ctx = this.ctx;
|
|
123
123
|
const referer = ctx.req.headers["referer"];
|
|
124
124
|
let redirectUrl;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-auth-wechat",
|
|
3
3
|
"displayName": "Auth: WeChat",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"description": "WeChat authentication.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Authentication"
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
11
|
"dependencies": {},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@ant-design/icons": "^
|
|
14
|
-
"@tachybase/schema": "1.
|
|
15
|
-
"@tego/client": "1.
|
|
16
|
-
"@tego/server": "1.
|
|
13
|
+
"@ant-design/icons": "^6.1.0",
|
|
14
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
15
|
+
"@tego/client": "1.6.0-alpha.9",
|
|
16
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
17
17
|
"antd": "5.22.5",
|
|
18
18
|
"dayjs": "1.11.13",
|
|
19
19
|
"react-i18next": "16.2.1",
|
|
20
20
|
"react-router-dom": "6.28.1",
|
|
21
|
-
"@tachybase/client": "1.
|
|
22
|
-
"@tachybase/module-auth": "1.
|
|
21
|
+
"@tachybase/client": "1.6.1",
|
|
22
|
+
"@tachybase/module-auth": "1.6.1"
|
|
23
23
|
},
|
|
24
24
|
"description.zh-CN": "通过微信扫码认证身份。",
|
|
25
25
|
"displayName.zh-CN": "认证:微信",
|