diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js index 770ccf9..0e0130f 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js @@ -5,10 +5,10 @@ const uuid = require('uuid'); async function check (ctx) { try { - const { models } = this.fs.dc; - const { Authorization } = ctx.headers; + const { models } = ctx.fs.dc; + const { authorization } = ctx.headers; const { utils: { oauthParseAuthHeader, oauthParseBody } } = ctx.app.fs - const keySplit = await oauthParseAuthHeader(Authorization); + const keySplit = await oauthParseAuthHeader(authorization); const existRes = await models.Application.findOne({ where: { appKey: keySplit[0], @@ -16,18 +16,15 @@ async function check (ctx) { } }) if (!existRes) { - throw '应用不存在' + throw new Error('应用不存在'); } else if (existRes.forbidden) { - throw '应用已被禁用' + throw new Error('应用已被禁用'); } ctx.status = 204; } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; - ctx.body = - typeof error == 'string' ? { - message: error - } : error + ctx.body = error } } diff --git a/code/VideoAccess-VCMP/api/app/lib/utils/oauth2.js b/code/VideoAccess-VCMP/api/app/lib/utils/oauth2.js index e844dad..88d6608 100644 --- a/code/VideoAccess-VCMP/api/app/lib/utils/oauth2.js +++ b/code/VideoAccess-VCMP/api/app/lib/utils/oauth2.js @@ -1,3 +1,5 @@ +const fs = require('fs'); + module.exports = function (app, opts) { async function oauthParseAuthHeader (auth) { if (!auth) { diff --git a/code/VideoAccess-VCMP/api/config.js b/code/VideoAccess-VCMP/api/config.js index 014e51c..1106420 100644 --- a/code/VideoAccess-VCMP/api/config.js +++ b/code/VideoAccess-VCMP/api/config.js @@ -93,6 +93,7 @@ const product = { dev, exclude: [ { p: '/camera', o: 'GET' }, // 暂时滴 + { p: '/application/check', o: 'GET' }, // 暂时滴 ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 redis: { host: IOTA_REDIS_SERVER_HOST,