Browse Source

公用接口验证方法更新

laiguoran 5 years ago
parent
commit
b6f187aa8f
1 changed files with 4 additions and 1 deletions
  1. 4 1
      app/middleware/api2other_check.js

+ 4 - 1
app/middleware/api2other_check.js

@@ -23,7 +23,7 @@ module.exports = options => {
             if (!code || !sign || !time) {
             if (!code || !sign || !time) {
                 throw '参数有误';
                 throw '参数有误';
             }
             }
-            if (parseFloat(time + 86400 * 1000) < new Date().getTime()) {
+            if ((parseFloat(time) + 86400 * 1000) < new Date().getTime()) {
                 throw '时间参数已过期';
                 throw '时间参数已过期';
             }
             }
             const data = yield this.service.project.getProjectByCode(code.toString().trim());
             const data = yield this.service.project.getProjectByCode(code.toString().trim());
@@ -33,6 +33,9 @@ module.exports = options => {
             if (data.custom === 0) {
             if (data.custom === 0) {
                 throw '无法通过接口登录本系统';
                 throw '无法通过接口登录本系统';
             }
             }
+            if (data.custom === 1 && data.can_api === 0) {
+                throw '接口已关闭,无法使用';
+            }
             const encryptSign = crypto.createHash('md5').update(data.code + data.secret + time.toString()).digest('hex').toString();
             const encryptSign = crypto.createHash('md5').update(data.code + data.secret + time.toString()).digest('hex').toString();
             if (encryptSign !== sign) {
             if (encryptSign !== sign) {
                 throw '参数验证失败';
                 throw '参数验证失败';