Commit 13a2d60f authored by tywldx's avatar tywldx

f

parent 86f33567
...@@ -165,32 +165,34 @@ app.use(async (ctx, next) => { ...@@ -165,32 +165,34 @@ app.use(async (ctx, next) => {
} else { } else {
// filter // filter
ctx.logger = logger; ctx.logger = logger;
if (config.site.env !== 'development' && urlFilter(ctx.request.url)) { ctx.user = {};
let token = ctx.header['x-token']; await next();
if (token) { // if (config.site.env !== 'development' && urlFilter(ctx.request.url)) {
if (session[token] == undefined) { // let token = ctx.header['x-token'];
let info = await requestPromise({ // if (token) {
url: `http://user.liangkebang.com/user/check_token?token=${token}`, // if (session[token] == undefined) {
method: "GET" // let info = await requestPromise({
}) // url: `http://user.liangkebang.com/user/check_token?token=${token}`,
info = JSON.parse(info); // method: "GET"
if (info.code == '0000') { // })
// 验证通过 // info = JSON.parse(info);
ctx.user = JSON.stringify(info); // if (info.code == '0000') {
session[token] = info; // // 验证通过
await next(); // ctx.user = JSON.stringify(info);
return; // session[token] = info;
} // await next();
} else { // return;
ctx.user = session[token]; // }
await next(); // } else {
return; // ctx.user = session[token];
} // await next();
} // return;
ctx.status = 401; // }
} else { // }
await next(); // ctx.status = 401;
} // } else {
// await next();
// }
} }
}) })
app.use(Middles.vhost(vhosts)); 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