Commit 13a2d60f authored by tywldx's avatar tywldx

f

parent 86f33567
......@@ -165,32 +165,34 @@ app.use(async (ctx, next) => {
} else {
// filter
ctx.logger = logger;
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();
}
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();
// }
}
})
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