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." });
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -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(),
|
||||
});
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user