user Id send from the request
This commit is contained in:
parent
01d5c7a1c0
commit
9d3c006343
@ -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) {
|
||||||
|
|||||||
@ -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(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user