From 9d3c006343257b29f05a7664b56b12573abf65c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Nov 2025 19:53:15 +0530 Subject: [PATCH] user Id send from the request --- app/controllers/products.controller.js | 6 +++--- app/controllers/unitMasterController.js | 6 +++--- app/routes/routes.js | 6 ------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/controllers/products.controller.js b/app/controllers/products.controller.js index f84dc92..a077e49 100644 --- a/app/controllers/products.controller.js +++ b/app/controllers/products.controller.js @@ -240,9 +240,9 @@ exports.uploadProductsFromCSV = async (req, res) => { return res.status(400).send({ status: "failed", message: "Invalid file type. Only CSV allowed." }); } - if (!req.body.created_by || isNaN(req.body.created_by)) { + if (!req.user.id || isNaN(req.user.id)) { fs.unlinkSync(filePath); - return res.status(400).send({ status: "failed", message: "Invalid or missing created_by." }); + return res.status(400).send({ status: "failed", message: "Invalid or missing User Id." }); } const mode = req.body.mode?.toLowerCase() || "add"; @@ -252,7 +252,7 @@ exports.uploadProductsFromCSV = async (req, res) => { } const results = []; - const userId = parseInt(req.body.created_by); + const userId = parseInt(req.user.id); const stats = fs.statSync(filePath); if (stats.size === 0) { diff --git a/app/controllers/unitMasterController.js b/app/controllers/unitMasterController.js index 1baa530..a9f3e6f 100644 --- a/app/controllers/unitMasterController.js +++ b/app/controllers/unitMasterController.js @@ -97,11 +97,11 @@ exports.uploadUnitMasterFromCSV = async (req, res) => { } // Validate created_by - if (!req.body.created_by || isNaN(req.body.created_by)) { + if (!req.user.id || isNaN(req.user.id)) { fs.unlinkSync(filePath); return res.status(400).send({ status: "failed", - message: "Invalid or missing created_by.", + message: "Invalid or missing User Id.", }); } @@ -244,7 +244,7 @@ exports.uploadUnitMasterFromCSV = async (req, res) => { uom_short_name: uomShort, uom: uom, description: description || null, - created_by: parseInt(req.body.created_by), + created_by: parseInt(req.user.id), created_at: new Date(), }); diff --git a/app/routes/routes.js b/app/routes/routes.js index 4a3d7fa..bc3ce5c 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -1157,9 +1157,6 @@ router.delete("/products/:id",[verifySignature, verifyToken], productController. * type: string * format: binary * description: CSV file to upload - * created_by: - * type: integer - * description: ID of the user performing the upload * responses: * 201: * description: Products uploaded successfully @@ -1795,9 +1792,6 @@ router.delete("/unit_master/:id",[verifySignature, verifyToken], unitMasterContr * type: string * format: binary * description: CSV file to upload - * created_by: - * type: integer - * description: ID of the user performing the upload * responses: * 201: * description: Unit Master file uploaded successfully