mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
fix: login 报错bug
This commit is contained in:
parent
469119aa7b
commit
18d220f738
@ -89,12 +89,19 @@ class baseController {
|
||||
async checkLogin(ctx) {
|
||||
let token = ctx.cookies.get('_yapi_token');
|
||||
let uid = ctx.cookies.get('_yapi_uid');
|
||||
|
||||
try {
|
||||
if (!token || !uid) return false;
|
||||
let userInst = yapi.getInst(userModel); //创建user实体
|
||||
let result = await userInst.findById(uid);
|
||||
let decoded = jwt.verify(token, result.passsalt);
|
||||
if(!result) return false;
|
||||
|
||||
let decoded;
|
||||
try{
|
||||
decoded = jwt.verify(token, result.passsalt);
|
||||
}catch(err){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (decoded.uid == uid) {
|
||||
this.$uid = uid;
|
||||
|
Loading…
Reference in New Issue
Block a user