Fixed hardcoded id in /me query (whoops)

This commit is contained in:
2025-09-19 09:04:48 -04:00
parent 7524cb591a
commit 9f9e15700f
2 changed files with 38 additions and 3 deletions

View File

@@ -32,9 +32,27 @@ router.get('/', async (req, res) => {
}
});
router.get('/me', (req, res) => {
router.get('/me', async (req, res) => {
console.log(req.user);
res.json(req.user);
if (req.user === undefined)
return res.sendStatus(401)
try {
const LOAData = await pool.query(
`SELECT *
FROM leave_of_absences
WHERE member_id = ?
AND deleted = 0
AND UTC_TIMESTAMP() BETWEEN start_date AND end_date;`, req.user.id)
const userWithLOA = {
...req.user,
loa: LOAData
};
res.json(userWithLOA);
} catch (error) {
console.error('Error fetching LOA data:', error);
return res.status(500).json({ error: 'Failed to fetch user data' });
}
})
router.get('/:id', async (req, res) => {