From c976b38ec4e5ad96658b86cfff088e8898a8c63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Iglesias=20Pr=C3=A9stamo?= <65736636+angelip2303@users.noreply.github.com> Date: Tue, 3 May 2022 23:06:22 +0200 Subject: [PATCH] Update OrderController.ts --- restapi/orders/OrderController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/restapi/orders/OrderController.ts b/restapi/orders/OrderController.ts index 5cb6b10..763589a 100644 --- a/restapi/orders/OrderController.ts +++ b/restapi/orders/OrderController.ts @@ -6,12 +6,14 @@ import { orderModel } from "./Order"; export const getOrder: RequestHandler = async (req, res) => { const webId = req.headers.token + ""; + const user = await userModel.findOne({ webId: webId }); + if (await verifyWebID(webId)) { const orderFound = await orderModel.findOne({ code: req.params.code, }); if (orderFound) { - if (webId === orderFound.webId) { + if (webId === orderFound.webId || user.role !== "user") { return res.json(orderFound); } else { return res.status(409).json();