From 7c36bd7245edc01c5c882767656a2d9dae6c6d5d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 24 Sep 2024 17:33:51 +0530 Subject: [PATCH] feat: use User for current user --- server/src/routes/auth.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts index a221a07c..4c578db8 100644 --- a/server/src/routes/auth.ts +++ b/server/src/routes/auth.ts @@ -65,7 +65,9 @@ router.get('/logout', async (req, res) => { router.get('/current-user', async (req, res) => { try { - const user = await User.findById(req.user._id).select('-password').exec(); + const user = await User.findByPk(req.user.id, { + attributes: { exclude: ['password'] }, + }); return res.status(200).json({ ok: true }); } catch (error) { return res.status(500).send(`Could not fetch current user : ${error.message}.`);