修复权限验证问题

This commit is contained in:
HelloWorld 2020-03-25 10:55:36 +08:00
parent 78b7dd36c2
commit 39f5cfc1c7
2 changed files with 204 additions and 206 deletions

View File

@ -70,7 +70,7 @@ exports.session = {
verify: {
// verify options is not required
},
verifyCallback: (error) => { throw new Error("token verify error"); }, // default verify fail callback
verifyCallback: any => any, // default verify fail callback
}
}

View File

@ -12,8 +12,7 @@ module.exports = class extends Base {
}
try {
let user = await this.session('user');
console.log(".......session user", this.ctx.action, Object.keys(user));
if (think.isEmpty(user)) {
if (think.isEmpty(user.id)) {
return this.fail(401, '请先登录');
}
this.ctx.state.user = user;
@ -57,7 +56,6 @@ module.exports = class extends Base {
});
data.token = token;
this.json({ code: 0, data, msg: "登陆成功" });
}
} catch (error) {
this.json({ code: 1, data: '', msg: error.toString() });