API: Properly handle not found cases for groups and characters
This commit is contained in:
@@ -28,7 +28,7 @@ router.get('/characters', async (req, res) => {
|
|||||||
router.get('/characters/:character_id', async (req, res) => {
|
router.get('/characters/:character_id', async (req, res) => {
|
||||||
let character = await Character.findByPk(req.params.character_id);
|
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' });
|
res.status(404).json({ error: 'Character not found' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ router.get('/groups', async (req, res) => {
|
|||||||
router.get('/groups/:group_id', async (req, res) => {
|
router.get('/groups/:group_id', async (req, res) => {
|
||||||
let group = await Group.findByPk(req.params.group_id);
|
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' });
|
res.status(404).json({ error: 'Group not found' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user