abler-api 0.1.12 → 0.1.15
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/cjs/pp-util.js +8 -4
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -530,7 +530,10 @@ class apiUtil$1 {
|
|
|
530
530
|
|
|
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
|
+
const expireTime = apiUtil$1.tokenExpireTime(req);
|
|
535
|
+
await apiUtil$1.restoreTokenData(tokenKey, expireTime);
|
|
536
|
+
return await apiUtil$1.restoreTokenData(tokenKey, expireTime).then(async function (data) {
|
|
534
537
|
req.userInfo = apiUtil$1.setUserIdNo(data, data._idNo);
|
|
535
538
|
if (req.tokenValidater) await req.tokenValidater(req.userInfo, req);
|
|
536
539
|
return true;
|
|
@@ -1047,11 +1050,12 @@ class apiUtil$1 {
|
|
|
1047
1050
|
static async $checkToken(req, res, next) {
|
|
1048
1051
|
try {
|
|
1049
1052
|
await apiUtil$1.checkRequestToken(req);
|
|
1050
|
-
|
|
1053
|
+
await next();
|
|
1051
1054
|
} catch (e) {
|
|
1052
1055
|
res.send(err.ERROR(e));
|
|
1053
|
-
return false;
|
|
1054
1056
|
}
|
|
1057
|
+
|
|
1058
|
+
return false;
|
|
1055
1059
|
}
|
|
1056
1060
|
/**
|
|
1057
1061
|
* 检查令牌,若存在则将其用户信息置入req
|
|
@@ -1205,7 +1209,7 @@ class apiUtil$1 {
|
|
|
1205
1209
|
|
|
1206
1210
|
req.isApiCall = true;
|
|
1207
1211
|
req.tokenData = p;
|
|
1208
|
-
apiUtil$1.$checkApiKeyOld(req, res, next);
|
|
1212
|
+
return apiUtil$1.$checkApiKeyOld(req, res, next);
|
|
1209
1213
|
}).catch(e => {
|
|
1210
1214
|
apiUtil$1.sendOrRedirect(req, res, apiUtil$1.spoApiFail(err.TOKEN_INVALID, req));
|
|
1211
1215
|
});
|