Fixed hardcoded id in /me query (whoops)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user