From 3ec781cc76c5fac87bb1e7452b4a553548b89f03 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sat, 4 Feb 2023 10:29:39 +0800 Subject: [PATCH] fix delete check --- pages/api/record.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pages/api/record.ts b/pages/api/record.ts index 054eab1..bfce8ac 100644 --- a/pages/api/record.ts +++ b/pages/api/record.ts @@ -12,7 +12,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { }); return; } - const json = JSON.parse(req.body); + const json = req.body; console.log("request", json); if (json.checked) { let count = 0; @@ -36,6 +36,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { } store[json.name] = json.user; } else { + // check whether the request name match the taken name + if (store[json.name] !== json.user) { + res.status(403).json({ + error: `失败:您未选择到当前位置`, + }) + return; + } delete store[json.name]; } }