feat: use User for current user

This commit is contained in:
karishmas6
2024-09-24 17:33:51 +05:30
parent f26f8300d3
commit 7c36bd7245

View File

@@ -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}.`);