✨ feat(后台): 37sdk需求

This commit is contained in:
luying
2022-11-25 17:18:38 +08:00
parent 594a8ce96d
commit 76633e67a6
9 changed files with 99 additions and 9 deletions
+7 -1
View File
@@ -3,13 +3,14 @@ import { GMGroupModel } from '@db/GMGroup'
import { GMRecordModel } from '@db/GMRecord'
import { GM_API_TYPE, STATUS } from '@consts';
import { gameData } from '@pubUtils/data';
import { nowSeconds } from '@pubUtils/timeUtil';
module.exports = () => {
return async function tokenParser(ctx, next) {
if (!ctx.request.headers || !ctx.request.headers.token) {
console.error('token not found');
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
ctx.body = ctx.service.utils.resResult(STATUS.TOKEN_ERR);
return;
}
const user = await GMUserModel.getGmAccountByToken(ctx.request.headers.token);
@@ -18,6 +19,11 @@ module.exports = () => {
ctx.body = ctx.service.utils.resResult(STATUS.TOKEN_ERR);
return;
}
if((user?.expireTime||0) < nowSeconds()) {
ctx.body = ctx.service.utils.resResult(STATUS.TOKEN_ERR);
return;
}
const url = ctx.request.url;
let dicApi = gameData.apiByUrl.get(url);
if(!dicApi) {