feat: current user route
This commit is contained in:
@@ -74,11 +74,11 @@ router.get('/logout', async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentUser = async (req, res) => {
|
router.get('/current-user', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const user = await User.findById(req.user._id).select('-password').exec();
|
const user = await User.findById(req.user._id).select('-password').exec();
|
||||||
return res.status(200).json({ ok: true });
|
return res.status(200).json({ ok: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res.status(500).send(`Could not fetch current user : ${error.message}.`);
|
return res.status(500).send(`Could not fetch current user : ${error.message}.`);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
Reference in New Issue
Block a user