添加后台连接用的后端

This commit is contained in:
luying
2020-09-22 11:09:15 +08:00
parent 6e891ec756
commit bcbed5959f
48 changed files with 14845 additions and 2076 deletions

View File

@@ -0,0 +1,27 @@
import { GMUserModel } from '@db/GMUser';
module.exports = () => {
return async function tokenParser(ctx, next) {
console.log(ctx.request.headers)
if (!ctx.request.headers || !ctx.request.headers.token) {
console.error('token not found');
ctx.body = {
"status": "error",
"data": "账号未登录"
};
return;
}
const user = await GMUserModel.getGmAccountByToken(ctx.request.headers.token);
if (!user) {
console.error('token invalid');
ctx.body = {
"status": "error",
"data": "账号未登录"
};
return;
}
ctx.user = user;
await next();
};
};