fix(consume material): changes made to remove the rest of the auth needs

This commit is contained in:
2025-09-18 10:59:55 -05:00
parent bdc1e72fc1
commit 360549aaf4
3 changed files with 66 additions and 53 deletions

View File

@@ -13,7 +13,7 @@ type Data = {
runningNr: string;
lotNum: number;
};
export const consumeMaterial = async (data: Data, prod: any) => {
export const consumeMaterial = async (data: Data) => {
const { runningNr, lotNum } = data;
// replace the rn
@@ -28,12 +28,7 @@ export const consumeMaterial = async (data: Data, prod: any) => {
barcode = r?.data;
} catch (error) {
console.log(error);
createLog(
"error",
prod.user.username,
"logistics",
`Error getting barcode: ${error}`
);
createLog("error", "", "logistics", `Error getting barcode: ${error}`);
}
if (barcode.length === 0) {

View File

@@ -51,33 +51,29 @@ app.openapi(
);
}
apiHit(c, { endpoint: "/consume", lastBody: data });
const authHeader = c.req.header("Authorization");
const token = authHeader?.split("Bearer ")[1] || "";
//const authHeader = c.req.header("Authorization");
//const token = authHeader?.split("Bearer ")[1] || "";
//const payload = await verify(token, process.env.JWT_SECRET!);
try {
const payload = await verify(token, process.env.JWT_SECRET!);
try {
//return apiReturn(c, true, access?.message, access?.data, 200);
//return apiReturn(c, true, access?.message, access?.data, 200);
const consume = await consumeMaterial(data, payload);
return c.json(
{ success: consume?.success, message: consume?.message },
200
);
} catch (error) {
//console.log(error);
//return apiReturn(c, false, "Error in setting the user access", error, 400);
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
}
const consume = await consumeMaterial(data);
return c.json(
{ success: consume?.success, message: consume?.message },
200
);
} catch (error) {
return c.json({ success: false, message: "Unauthorized" }, 401);
//console.log(error);
//return apiReturn(c, false, "Error in setting the user access", error, 400);
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
}
}
);