user Id send from the request

This commit is contained in:
unknown 2025-11-10 19:53:15 +05:30
parent 01d5c7a1c0
commit 9d3c006343
3 changed files with 6 additions and 12 deletions

View File

@ -240,9 +240,9 @@ exports.uploadProductsFromCSV = async (req, res) => {
return res.status(400).send({ status: "failed", message: "Invalid file type. Only CSV allowed." }); 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); 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"; const mode = req.body.mode?.toLowerCase() || "add";
@ -252,7 +252,7 @@ exports.uploadProductsFromCSV = async (req, res) => {
} }
const results = []; const results = [];
const userId = parseInt(req.body.created_by); const userId = parseInt(req.user.id);
const stats = fs.statSync(filePath); const stats = fs.statSync(filePath);
if (stats.size === 0) { if (stats.size === 0) {

View File

@ -97,11 +97,11 @@ exports.uploadUnitMasterFromCSV = async (req, res) => {
} }
// Validate created_by // Validate created_by
if (!req.body.created_by || isNaN(req.body.created_by)) { if (!req.user.id || isNaN(req.user.id)) {
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
return res.status(400).send({ return res.status(400).send({
status: "failed", 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_short_name: uomShort,
uom: uom, uom: uom,
description: description || null, description: description || null,
created_by: parseInt(req.body.created_by), created_by: parseInt(req.user.id),
created_at: new Date(), created_at: new Date(),
}); });

View File

@ -1157,9 +1157,6 @@ router.delete("/products/:id",[verifySignature, verifyToken], productController.
* type: string * type: string
* format: binary * format: binary
* description: CSV file to upload * description: CSV file to upload
* created_by:
* type: integer
* description: ID of the user performing the upload
* responses: * responses:
* 201: * 201:
* description: Products uploaded successfully * description: Products uploaded successfully
@ -1795,9 +1792,6 @@ router.delete("/unit_master/:id",[verifySignature, verifyToken], unitMasterContr
* type: string * type: string
* format: binary * format: binary
* description: CSV file to upload * description: CSV file to upload
* created_by:
* type: integer
* description: ID of the user performing the upload
* responses: * responses:
* 201: * 201:
* description: Unit Master file uploaded successfully * description: Unit Master file uploaded successfully