q-koa 13.8.13 → 13.8.14

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.
Files changed (2) hide show
  1. package/core/app.js +13 -10
  2. package/package.json +1 -1
package/core/app.js CHANGED
@@ -214,17 +214,8 @@ class APP {
214
214
  }
215
215
 
216
216
  /**
217
- * 挂在jwt解密方法
217
+ * jwt sign 方法已在 initApp 时定义,此处跳过
218
218
  */
219
- if (this.app[appName]) {
220
- this.app[appName].sign = async (user) => {
221
- const result = await jwt.sign(user, secret, {
222
- expiresIn,
223
- algorithm: 'HS256',
224
- })
225
- return result
226
- }
227
- }
228
219
  // eslint-disable-next-line no-nested-ternary
229
220
  ctx.request.clientType = ctx.header['client-type']
230
221
  ? Number(ctx.header['client-type'])
@@ -518,6 +509,12 @@ class APP {
518
509
  { appName, ip: this.config.ip, port: this.port }
519
510
  ),
520
511
  }
512
+ const jwtCfg = this.app[appName].appConfig.jwt
513
+ this.app[appName].sign = (user) =>
514
+ jwt.sign(user, jwtCfg.secret, {
515
+ expiresIn: jwtCfg.expiresIn,
516
+ algorithm: 'HS256',
517
+ })
521
518
  } else {
522
519
  this.app[appName] = {
523
520
  sequelize: db,
@@ -528,6 +525,12 @@ class APP {
528
525
  { appName, ip: this.config.ip, port: this.port }
529
526
  ),
530
527
  }
528
+ const jwtCfg = this.app[appName].appConfig.jwt
529
+ this.app[appName].sign = (user) =>
530
+ jwt.sign(user, jwtCfg.secret, {
531
+ expiresIn: jwtCfg.expiresIn,
532
+ algorithm: 'HS256',
533
+ })
531
534
  }
532
535
 
533
536
  // const proxyConfig = _.get(this.app[appName], 'appConfig.proxy');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.8.13",
3
+ "version": "13.8.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {