API: Properly handle not found cases for groups and characters

This commit is contained in:
Minz committed 2023-04-17 16:00:12 +02:00
1 parent 3915956bea
commit aea807ca3c
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ router.get('/characters', async (req, res) => {
router.get('/characters/:character_id', async (req, res) => {
let character = await Character.findByPk(req.params.character_id);
if (!character.enabled && !isAuthorized(req)) {
if (!character || !character.enabled && !isAuthorized(req)) {
res.status(404).json({ error: 'Character not found' });
return;
}
+1 -1
View File
@@ -28,7 +28,7 @@ router.get('/groups', async (req, res) => {
router.get('/groups/:group_id', async (req, res) => {
let group = await Group.findByPk(req.params.group_id);
if (!group.enabled && !isAuthorized(req)) {
if (!group || !group.enabled && !isAuthorized(req)) {
res.status(404).json({ error: 'Group not found' });
return;
}