This commit is contained in:
2025-02-19 00:34:51 +08:00
parent cf1cc83547
commit 2f3ffe2a34
33 changed files with 3180 additions and 832 deletions

View File

@@ -10,6 +10,7 @@ module.exports = {
if(req.headers.hasOwnProperty("data")) {
try {
req.headers.data = rsa.PrivateKeyDecryption(req.headers.data)
// console.log("req.headers.data: ", req.headers.data);
if(req.url == config.filter.login || req.url == config.filter.add
|| req.url == config.filter.home
) {
@@ -19,8 +20,8 @@ module.exports = {
jwt.verify(req.headers.token,config.jwt,function(err,decode){
if(err){
res.json({
status: 501,
message: '身份凭证失效或不存在,请登录'
status: 403,
message: `身份凭证失效或不存在,请登录${err.message}`
})
}else{
next();
@@ -28,26 +29,21 @@ module.exports = {
});
} else { // 无token
res.json({
status: 500,
message: '缺少token参数请检查'
status: 403,
message: '无权限访问接口,您需要先登录才能使用!'
})
}
}
} catch (e) {
console.log("--------");
console.log("e --------: ", e);
console.log("--------");
res.json({
status: 500,
message: '抱歉,公钥加密有误,请检查公钥'
message: `抱歉,私钥解密出错!错误信息:${e.message}`
})
}
} else {
res.json({
status: 500,
message: '请求头缺少data参数'
message: '请求头缺少data字段'
})
}
}