From e2f53601f6dac9af0d025414dec4d216c9c6437a Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Sun, 23 May 2021 18:11:09 +0300 Subject: [PATCH] Check for Lanista token when POSTing league data --- pages/api/league/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pages/api/league/index.ts b/pages/api/league/index.ts index 26712accc..1296b6d4b 100644 --- a/pages/api/league/index.ts +++ b/pages/api/league/index.ts @@ -22,6 +22,13 @@ async function GET(req: NextApiRequest, res: NextApiResponse) { } async function POST(req: NextApiRequest, res: NextApiResponse) { + if ( + !req.body || + typeof req.body !== "object" || + req.body.token !== process.env.LANISTA_TOKEN + ) { + return res.status(401).end(); + } const parsed = z .array( z.object({ @@ -43,7 +50,7 @@ async function POST(req: NextApiRequest, res: NextApiResponse) { ), }) ) - .safeParse(req.body); + .safeParse(req.body.data); if (!parsed.success) { return res.status(400).send(parsed.error.message);