init
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user