diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-07-20 12:11:07 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-07-20 12:11:07 +0900 |
| commit | acb92442058fa2458967425efb7324ab0646a335 (patch) | |
| tree | afc2ac62a7bbddce5756fc49f1caba9f7cba5407 /src/server/api/api-handler.ts | |
| parent | Merge branch 'develop' (diff) | |
| parent | 12.84.0 (diff) | |
| download | misskey-acb92442058fa2458967425efb7324ab0646a335.tar.gz misskey-acb92442058fa2458967425efb7324ab0646a335.tar.bz2 misskey-acb92442058fa2458967425efb7324ab0646a335.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/server/api/api-handler.ts')
| -rw-r--r-- | src/server/api/api-handler.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts index 80a4fd97c8..cbace8917e 100644 --- a/src/server/api/api-handler.ts +++ b/src/server/api/api-handler.ts @@ -1,7 +1,7 @@ import * as Koa from 'koa'; import { IEndpoint } from './endpoints'; -import authenticate from './authenticate'; +import authenticate, { AuthenticationError } from './authenticate'; import call from './call'; import { ApiError } from './error'; @@ -37,11 +37,15 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => { }).catch((e: ApiError) => { reply(e.httpStatusCode ? e.httpStatusCode : e.kind === 'client' ? 400 : 500, e); }); - }).catch(() => { - reply(403, new ApiError({ - message: 'Authentication failed. Please ensure your token is correct.', - code: 'AUTHENTICATION_FAILED', - id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14' - })); + }).catch(e => { + if (e instanceof AuthenticationError) { + reply(403, new ApiError({ + message: 'Authentication failed. Please ensure your token is correct.', + code: 'AUTHENTICATION_FAILED', + id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14' + })); + } else { + reply(500, new ApiError()); + } }); }); |