From a6fdb28560c8562cc26d49a12cada7f731175fb9 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Sat, 11 Feb 2023 01:07:44 +0100 Subject: [PATCH] make secure check --- packages/backend/src/server/index.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index fbdc7db44..ade41d9ed 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -151,11 +151,14 @@ mastoRouter.post("/oauth/token", async (ctx) => { const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; const generator = (megalodon as any).default; const client = generator("misskey", BASE_URL, null) as MegalodonInterface; - const m = body.code.match(/^[a-zA-Z0-9-]+/); - if (!m.length) { - ctx.body = { error: "Invalid code" }; - return; - } + let m = null; + if (body.code) { + m = body.code.match(/^[a-zA-Z0-9-]+/); + if (!m.length) { + ctx.body = { error: "Invalid code" }; + return; + } + } try { const atData = await client.fetchAccessToken( null,