@tachybase/plugin-auth-wechat 1.6.0 → 1.6.3

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.
@@ -1,12 +1,12 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.6.0",
4
- "@ant-design/icons": "5.6.1",
3
+ "@tachybase/client": "1.6.3",
4
+ "@ant-design/icons": "6.1.0",
5
5
  "antd": "5.22.5",
6
- "@tachybase/module-auth": "1.6.0",
7
- "@tachybase/schema": "1.3.52",
6
+ "@tachybase/module-auth": "1.6.3",
7
+ "@tachybase/schema": "1.6.1",
8
8
  "react-router-dom": "6.28.1",
9
9
  "react-i18next": "16.2.1",
10
- "@tego/server": "1.3.52",
10
+ "@tego/server": "1.6.1",
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.app;
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.app.name;
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.app.authManager.jwt.sign({ userId: ctx.auth.user.id }, { expiresIn: `${import_constants.AUTH_TIMEOUT_MINUTE}m` });
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.app.authManager.get(authenticator, 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.app.authManager.jwt.decode(bindToken);
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 auth.bindUser(user.userId);
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
@@ -40,7 +40,8 @@ class WeChatAuth extends import_server.BaseAuth {
40
40
  const { ctx } = config;
41
41
  super({
42
42
  ...config,
43
- userCollection: ctx.db.getCollection("users")
43
+ userCollection: ctx.db.getCollection("users"),
44
+ userStatusCollection: ctx.db.getCollection("userStatuses")
44
45
  });
45
46
  }
46
47
  async validate() {
@@ -118,7 +119,7 @@ class WeChatAuth extends import_server.BaseAuth {
118
119
  async getAuthCfg(redirect) {
119
120
  var _a, _b;
120
121
  const appID = (_b = (_a = this.options) == null ? void 0 : _a.wechatAuth) == null ? void 0 : _b.AppID;
121
- const app = this.ctx.app.name;
122
+ const app = this.ctx.tego.name;
122
123
  const ctx = this.ctx;
123
124
  const referer = ctx.req.headers["referer"];
124
125
  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.6.0",
4
+ "version": "1.6.3",
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": "^5.6.1",
14
- "@tachybase/schema": "1.3.52",
15
- "@tego/client": "1.3.52",
16
- "@tego/server": "1.3.52",
13
+ "@ant-design/icons": "^6.1.0",
14
+ "@tachybase/schema": "1.6.1",
15
+ "@tego/client": "1.6.1",
16
+ "@tego/server": "1.6.1",
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.6.0",
22
- "@tachybase/module-auth": "1.6.0"
21
+ "@tachybase/client": "1.6.3",
22
+ "@tachybase/module-auth": "1.6.3"
23
23
  },
24
24
  "description.zh-CN": "通过微信扫码认证身份。",
25
25
  "displayName.zh-CN": "认证:微信",