feat: current user route

This commit is contained in:
karishmas6
2024-09-24 00:01:32 +05:30
parent 74ed86ba4b
commit 404eb797b9

View File

@@ -74,11 +74,11 @@ router.get('/logout', async (req, res) => {
}
})
const currentUser = async (req, res) => {
router.get('/current-user', async (req, res) => {
try {
const user = await User.findById(req.user._id).select('-password').exec();
return res.status(200).json({ ok: true });
} catch (error) {
return res.status(500).send(`Could not fetch current user : ${error.message}.`);
}
};
});