abler-api 0.1.13 → 0.1.16

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.
@@ -531,8 +531,8 @@ class apiUtil$1 {
531
531
  static async checkRequestToken(req) {
532
532
  req.accessToken = req.accessToken || apiUtil$1.extractToken(req);
533
533
  const tokenKey = apiUtil$1.userTokenStoreKey(req.accessToken);
534
- apiUtil$1.tokenExpireTime(req);
535
- await apiUtil$1.restoreTokenData(tokenKey, xpireTime).then(async function (data) {
534
+ const expireTime = apiUtil$1.tokenExpireTime(req);
535
+ return await apiUtil$1.restoreTokenData(tokenKey, expireTime).then(async function (data) {
536
536
  req.userInfo = apiUtil$1.setUserIdNo(data, data._idNo);
537
537
  if (req.tokenValidater) await req.tokenValidater(req.userInfo, req);
538
538
  return true;
@@ -1049,11 +1049,12 @@ class apiUtil$1 {
1049
1049
  static async $checkToken(req, res, next) {
1050
1050
  try {
1051
1051
  await apiUtil$1.checkRequestToken(req);
1052
- return true;
1052
+ await next();
1053
1053
  } catch (e) {
1054
1054
  res.send(err.ERROR(e));
1055
- return false;
1056
1055
  }
1056
+
1057
+ return false;
1057
1058
  }
1058
1059
  /**
1059
1060
  * 检查令牌,若存在则将其用户信息置入req
@@ -1207,7 +1208,7 @@ class apiUtil$1 {
1207
1208
 
1208
1209
  req.isApiCall = true;
1209
1210
  req.tokenData = p;
1210
- apiUtil$1.$checkApiKeyOld(req, res, next);
1211
+ return apiUtil$1.$checkApiKeyOld(req, res, next);
1211
1212
  }).catch(e => {
1212
1213
  apiUtil$1.sendOrRedirect(req, res, apiUtil$1.spoApiFail(err.TOKEN_INVALID, req));
1213
1214
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.13",
3
+ "version": "0.1.16",
4
4
  "description": "API服务相关工具",
5
5
  "main": "./dist/cjs/pp-util.js",
6
6
  "-module": "./dist/es/pp-util.js",