feat: return error if !user
This commit is contained in:
@@ -72,6 +72,9 @@ router.get('/current-user', async (req: AuthenticatedRequest, res) => {
|
|||||||
const user = await User.findByPk(req.user.id, {
|
const user = await User.findByPk(req.user.id, {
|
||||||
attributes: { exclude: ['password'] },
|
attributes: { exclude: ['password'] },
|
||||||
});
|
});
|
||||||
|
if (!user) {
|
||||||
|
return res.status(404).json({ ok: false, error: 'User not found' });
|
||||||
|
}
|
||||||
return res.status(200).json({ ok: true });
|
return res.status(200).json({ ok: true });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
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