Commit ce427671 authored by tywldx's avatar tywldx

f

parent 1ac9266f
......@@ -199,33 +199,34 @@ app.use(async (ctx, next) => {
// filter
ctx.logger = logger;
ctx.user = {};
await next();
// if (config.site.env !== 'development' && urlFilter(ctx.request.url)) {
// let token = ctx.header['x-token'];
// if (token) {
// if (session[token] == undefined) {
// let info = await requestPromise({
// url: `http://user.liangkebang.com/user/check_token?token=${token}`,
// method: "GET"
// })
// info = JSON.parse(info);
// if (info.code == '0000') {
// // 验证通过
// ctx.user = JSON.stringify(info);
// session[token] = info;
// await next();
// return;
// }
// } else {
// ctx.user = session[token];
// await next();
// return;
// }
// }
// ctx.status = 401;
// } else {
// await next();
// }
if (config.site.env !== 'development' && urlFilter(ctx.request.url)) {
let token = ctx.header['x-token'];
if (token) {
if (session[token] == undefined) {
let info = await requestPromise({
url: `http://user.liangkebang.com/user/check_token?token=${token}`,
method: "GET"
})
info = JSON.parse(info);
if (info.code == '0000') {
// 验证通过
ctx.user = JSON.stringify(info);
session[token] = info;
await next();
return;
}
} else {
ctx.user = session[token];
await next();
return;
}
}
ctx.status = 401;
// await next();
return;
} else {
await next();
}
}
})
app.use(Middles.vhost(vhosts));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment