fix: raise forbidden when viewing invisible track and not author
This commit is contained in:
parent
fb11a71663
commit
2da013583b
|
@ -332,6 +332,11 @@ router.get(
|
||||||
req.payload ? User.findById(req.payload.id) : null,
|
req.payload ? User.findById(req.payload.id) : null,
|
||||||
req.track.populate('author').execPopulate(),
|
req.track.populate('author').execPopulate(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!req.track.visible && req.track.author._id.toString() !== req.payload?.id?.toString()) {
|
||||||
|
return res.sendStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
return res.json({ track: req.track.toJSONFor(user, { body: true }) });
|
return res.json({ track: req.track.toJSONFor(user, { body: true }) });
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue