Commit 82ef9e02 by 庄冰

baidu

parent c7b40412
......@@ -49,7 +49,7 @@ class APIBase {
//保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 3600);
}
result.requestId = pobj.RequestId ? pobj.RequestId : pobj.requestId || this.getUUID();
result.requestId = pobj.RequestId ? pobj.RequestId : pobj.requestId || req.requestId;
var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : { status: result.status, message: result.message, requestId: result.requestId };
this.execClientNew.execLogs("reqPath:" + req.path, pobj, "center-channel-doexecMethod", tmpResult, null);
return result;
......
......@@ -552,6 +552,31 @@ module.exports = function (app) {
res.end(JSON.stringify(result));
return;
}
// var token = req.headers["token"] || "";
// if (!token) {
// var resfail = {
// "success": false,
// "errorMsg": "req headers token can not be empty",
// "errorCode": "ok"
// };
// res.end(JSON.stringify(resfail));
// return;
// }
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// if (result.status != 0) {
// var resfail = {
// "success": false,
// "errorMsg": result.msg || "token error",
// "errorCode": "ok"
// };
// res.end(JSON.stringify(resfail));
// // res.end(JSON.stringify(result));
// return;
// }
// req.appInfo = result.data;
// req.body.appInfo = result.data;
// req.actionProcess = result.data.app_code;
var token = req.headers["token"] || "";
if (!token) {
var resfail = {
......@@ -562,21 +587,24 @@ module.exports = function (app) {
res.end(JSON.stringify(resfail));
return;
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
if (result.status != 0) {
var resfail = {
"success": false,
"errorMsg": result.msg || "token error",
"errorCode": "ok"
};
res.end(JSON.stringify(resfail));
// res.end(JSON.stringify(result));
return;
//校验jwt产生的token
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
let token_secret_str = null;
jwt.verify(token, tokenSecret, function (err, decoded) { // decoded:指的是token解码后用户信息
if (err) { //如果token过期则会执行err的代码块
return res.send(system.getResultFail(-88, "Failed to authenticate token,error:" + err));
} else {
token_secret_str = decoded.token_secret;
}
});
let decryptResult = await utilsAuthSve.decryptInfo(token_secret_str);
if (decryptResult.status != 0) {
return res.send(system.getResultFail(-88, "Failed to authenticate token,fail:" + decryptResult.msg));
}
req.appInfo = result.data;
req.body.appInfo = result.data;
req.actionProcess = result.data.app_code;
let tmpAppInfo = JSON.parse(decryptResult.data);
req.body.appInfo = tmpAppInfo;
req.appInfo = tmpAppInfo;
req.actionProcess = tmpAppInfo.app_code;
next();
});
//icp需求推送
......
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