From 170f9085a681c105ec1b164d862d697007ddc9f1 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 22 Jan 2024 19:41:25 +0100 Subject: [PATCH] employee view --- src/controllers/userController.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/controllers/userController.ts b/src/controllers/userController.ts index 81bead8..9c1531b 100644 --- a/src/controllers/userController.ts +++ b/src/controllers/userController.ts @@ -227,6 +227,13 @@ export async function GetUser(req: Request, res: Response) { attributes: ["store_id", "name"], }); + let respData = { + user: user, + stores: stores, + // only temporary until we have a proper permissions system + permissions: [] as string[], + }; + // if user is not a store master, then check if user is a worker if (!stores || stores.length === 0) { const store = await Store.findOne({ @@ -241,9 +248,20 @@ export async function GetUser(req: Request, res: Response) { } stores.push(store); + + respData.stores = stores; + + respData.permissions.push("calendar"); + } else { + respData.permissions.push( + "settings", + "employees", + "services", + "calendar" + ); } - res.status(200).send({ user, stores }); + res.status(200).send(respData); } catch (error) { logger.error(error); res.status(500).send({ err: "invalid request" });