feat: get current user
This commit is contained in:
@@ -71,3 +71,12 @@ const logout = async (req, res) => {
|
||||
res.status(500).send(`Could not logout user - ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
const currentUser = 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}.`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user