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." });
}
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) {

View File

@ -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(),
});

View File

@ -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