From 084f2a1b7fee8162e6df50f497c0622ae9839af9 Mon Sep 17 00:00:00 2001 From: Rohit Rajan Date: Thu, 4 Dec 2025 15:11:04 +0530 Subject: [PATCH] fix: get auth user's id --- server/src/routes/auth.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts index 34933466..5a758ee9 100644 --- a/server/src/routes/auth.ts +++ b/server/src/routes/auth.ts @@ -210,12 +210,13 @@ router.get( requireSignIn, async (req: AuthenticatedRequest, res) => { try { - const { id } = req.params; - if (!id) { - return res.status(400).json({ message: "User ID is required" }); + if (!req.user || !req.user.id) { + return res.status(401).json({ message: "Unauthorized" }); } - const user = await User.findByPk(id, { + const userId = req.user.id; + + const user = await User.findByPk(userId, { attributes: { exclude: ["password"] }, });