Commit 79c97af3 by 王昆

gsb

parent 56ea3fb2
......@@ -85,22 +85,23 @@ class ActionAPI extends APIBase {
let timestamp = Number(params.timestamp);
let nonceStr = Number(params.nonceStr);
let now = new Date().getTime();
if (now - timestamp > 60 * 1000) {
return system.getResult(1000000, "请求超时");
if (now - timestamp > 60 * 60 * 60 * 1000) {
return system.getResultFail(1000000, "请求超时");
}
if (!appId) {
return system.getResult(1000000, "请填写appId");
return system.getResultFail(1000000, "请填写appId");
}
if (!nonceStr) {
return system.getResult(1000000, "随机码为空");
return system.getResultFail(1000000, "随机码为空");
}
// TODO redis通过sign幂等验证
// 幂等验证代码xxxx
let app = await this.merchantSve.apiInfo({id: appId}).data || {};
if (!app.id) {
return system.getResult(1000000, "appId不存在");
let app = await this.merchantSve.apiInfo({id: appId})
if (!app.data || !app.data.id) {
return system.getResultFail(1000000, "appId不存在");
}
app = app.data;
let keys = Object.keys(params).sort();
let signArr = [];
......@@ -112,9 +113,11 @@ class ActionAPI extends APIBase {
}
let sign = md5(signArr.join("&") + "&key=" + app.secret).toUpperCase();
console.log(params.sign, sign);
if (params.sign != sign) {
return system.getResult(1001001, "签名验证失败");
return system.getResultFail(1001001, "签名验证失败");
}
return system.getResultSuccess();
}
exam() {
......
......@@ -6,7 +6,7 @@ var settings={
db:10,
},
database:{
dbname : "esign-sve-uc",
dbname : "esign-api",
user: "write",
password: "write",
config: {
......
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