summary refs log tree commit diff
path: root/src/api/routes/users/#id/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/users/#id/index.ts')
-rw-r--r--src/api/routes/users/#id/index.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/api/routes/users/#id/index.ts b/src/api/routes/users/#id/index.ts
index 1bd413d3..dd47a0cd 100644
--- a/src/api/routes/users/#id/index.ts
+++ b/src/api/routes/users/#id/index.ts
@@ -17,7 +17,7 @@
 */
 
 import { route } from "@spacebar/api";
-import { User } from "@spacebar/util";
+import { User, getRights } from "@spacebar/util";
 import { Request, Response, Router } from "express";
 
 const router: Router = Router();
@@ -33,8 +33,15 @@ router.get(
 	}),
 	async (req: Request, res: Response) => {
 		const { id } = req.params;
+		const rights = await getRights(req.user_id);
 
-		res.json(await User.getPublicUser(id));
+		const user = await User.findOneOrFail({ where: { id } });
+
+		res.json(
+			rights.has("OPERATOR")
+				? await user.toPrivateUser()
+				: await user.toPublicUser(),
+		);
 	},
 );