|
@ -5,10 +5,10 @@ const uuid = require('uuid'); |
|
|
|
|
|
|
|
|
async function check (ctx) { |
|
|
async function check (ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = this.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { Authorization } = ctx.headers; |
|
|
const { authorization } = ctx.headers; |
|
|
const { utils: { oauthParseAuthHeader, oauthParseBody } } = ctx.app.fs |
|
|
const { utils: { oauthParseAuthHeader, oauthParseBody } } = ctx.app.fs |
|
|
const keySplit = await oauthParseAuthHeader(Authorization); |
|
|
const keySplit = await oauthParseAuthHeader(authorization); |
|
|
const existRes = await models.Application.findOne({ |
|
|
const existRes = await models.Application.findOne({ |
|
|
where: { |
|
|
where: { |
|
|
appKey: keySplit[0], |
|
|
appKey: keySplit[0], |
|
@ -16,18 +16,15 @@ async function check (ctx) { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if (!existRes) { |
|
|
if (!existRes) { |
|
|
throw '应用不存在' |
|
|
throw new Error('应用不存在'); |
|
|
} else if (existRes.forbidden) { |
|
|
} else if (existRes.forbidden) { |
|
|
throw '应用已被禁用' |
|
|
throw new Error('应用已被禁用'); |
|
|
} |
|
|
} |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|
ctx.body = |
|
|
ctx.body = error |
|
|
typeof error == 'string' ? { |
|
|
|
|
|
message: error |
|
|
|
|
|
} : error |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|