wip
This commit is contained in:
@ -7,6 +7,8 @@ import { IUser } from '../../models/user';
|
||||
import { IApp } from '../../models/app';
|
||||
|
||||
export default async (endpoint: Endpoint, ctx: Koa.Context) => {
|
||||
const body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body;
|
||||
|
||||
const reply = (x?: any, y?: any) => {
|
||||
if (x === undefined) {
|
||||
ctx.status = 204;
|
||||
@ -25,7 +27,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
|
||||
|
||||
// Authentication
|
||||
try {
|
||||
[user, app] = await authenticate(ctx.request.body['i']);
|
||||
[user, app] = await authenticate(body['i']);
|
||||
} catch (e) {
|
||||
reply(403, 'AUTHENTICATION_FAILED');
|
||||
return;
|
||||
@ -35,7 +37,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
|
||||
|
||||
// API invoking
|
||||
try {
|
||||
res = await call(endpoint, user, app, ctx.request.body, ctx.req);
|
||||
res = await call(endpoint, user, app, body, (ctx.req as any).file);
|
||||
} catch (e) {
|
||||
reply(400, e);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user