This commit is contained in:
xy
2026-03-13 01:38:40 +00:00
parent e6e4f88257
commit 28855885cd
311 changed files with 89544 additions and 94350 deletions
+5 -3
View File
@@ -2,17 +2,19 @@ import { GMUserModel } from '@db/GMUser';
import { GMGroupModel } from '@db/GMGroup'
import { GMRecordModel } from '@db/GMRecord'
import { GM_API_TYPE, STATUS } from '@consts';
import { gameData } from 'app/pubUtils/data';
import { gameData } from '@pubUtils/data';
import { Context } from 'egg';
module.exports = () => {
return async function tokenParser(ctx, next) {
return async function tokenParser(ctx: Context, next: () => Promise<any>) {
if (!ctx.request.headers || !ctx.request.headers.token) {
console.error('token not found');
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return;
}
const user = await GMUserModel.getGmAccountByToken(ctx.request.headers.token);
const token = typeof ctx.request.headers.token === 'string' ? ctx.request.headers.token : ctx.request.headers.token[0];
const user = await GMUserModel.getGmAccountByToken(token);
if (!user) {
console.error('token invalid');
ctx.body = ctx.service.utils.resResult(STATUS.TOKEN_ERR);