Skip to content

Commit

Permalink
Fix error catching to check if token is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickTle924 committed Jan 15, 2025
1 parent 30f8cfa commit bdd4544
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/main_endpoints/routes/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ router.post('/send', async (req, res) => {
res.sendStatus(SERVER_ERROR);
}
} else {
if (token) {
userObj = decodeToken(req);
if (!userObj) {
return res.sendStatus(UNAUTHORIZED);
}
}
writeMessage(id, `${message}`, `${name}:`);
return res.json({ status: 'Message sent!' });
}
Expand Down

0 comments on commit bdd4544

Please sign in to comment.