diff --git a/src/handlers/user.ts b/src/handlers/user.ts index dc3e05f07f209e9c074cccb6f7685af056c02785..b05921e17afbf7c33014c9cdefd10da9e7c39f1f 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 "}); }