From c097f4e904eb16e03a4ca845593cc7f7f9a63c75 Mon Sep 17 00:00:00 2001 From: Faisal Sayed Date: Wed, 17 Apr 2024 16:22:06 -0400 Subject: [PATCH] fix: fix lookup api route --- src/pages/api/lookup.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/api/lookup.ts b/src/pages/api/lookup.ts index b409758..87c6505 100644 --- a/src/pages/api/lookup.ts +++ b/src/pages/api/lookup.ts @@ -4,26 +4,26 @@ import type { NextApiRequest, NextApiResponse } from "next"; // POST - /api/lookup - Lookup verification status for a user export default async function handler(req: NextApiRequest, res: NextApiResponse) { - const body = req.body; - const userId = body.text.split("|")[0].slice(2); - if (!userId) return res.status(400).json({ message: "Invalid user" }); + const data = req.body; + const email = data.text; + if (!email) return res.status(400).json({ message: "Invalid user" }); - if (!admins.includes(body.user_id)) return res.status(401).json({ message: "Unauthorized" }); + if (!admins.includes(data.user_id)) return res.status(401).json({ message: "Unauthorized" }); try { const record = await base("Users") - .select({ filterByFormula: `{Hack Club Slack ID} = '${userId}'` }) + .select({ filterByFormula: `{Email} = '${email}'` }) .firstPage(); if (record.length > 0) { return res .status(200) - .json(`Verification Status for <@${userId}>: ${record[0].fields["Verification Status"]}`); + .json(`Verification Status for ${email}: ${record[0].fields["Verification Status"]}`); } else { return res .status(200) .json( - `User <@${userId}> not verified. Ask them to head over to https://verify.hackclub.dev to get verified.` + `User ${email} not found or not verified. Ask them to head over to https://verify.hackclub.dev to get verified.` ); } } catch (error: any) {