From f55d87ae4c5444cd6ffa633d15416f0ec6f81aa8 Mon Sep 17 00:00:00 2001 From: Ricardo <ricardofaria170@gmail.com> Date: Fri, 21 Mar 2025 11:58:59 -0300 Subject: [PATCH] FIX update id verification --- src/handlers/user.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/handlers/user.ts b/src/handlers/user.ts index dc3e05f..b05921e 100644 --- a/src/handlers/user.ts +++ b/src/handlers/user.ts @@ -23,13 +23,19 @@ export default class User{ } - static async updateUser (id: number, req: Request, res:Response): Promise<any>{ + static async updateUser (req: Request, res:Response): Promise<any>{ if (!this.userRequestValidation(req)) { return res.status(400).json({ erro: "Invalid Request" }); } - if (!(await this.userExistenceValidation(id))) + const { id } = req.params; + const parsedId = parseInt(id, 10); + if (isNaN(parsedId)) { + return res.status(400).json({ error: "ID inválido" }); + } + + if (!(await this.userExistenceValidation(parsedId))) { return res.status(404).json({ error: "Not Found "}); } -- GitLab