Skip to content

Node.js based forum software built for the modern web

fix: #14007, deny access for guests to topics in cid -1, unless a post from a local user exists

Julian Lamde4f016f50ab
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index a459c3a99f..d5df96bf9e 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -41,10 +41,12 @@ topicsController.get = async function getTopic(req, res, next) {
userPrivileges,
settings,
rssToken,
+ uids,
] = await Promise.all([
privileges.topics.get(tid, req.uid),
user.getSettings(req.uid),
user.auth.getFeedToken(req.uid),
+ topics.getUids(tid),
]);
let currentPage = parseInt(req.query.page, 10) || 1;
@@ -53,7 +55,8 @@ topicsController.get = async function getTopic(req, res, next) {
if (
userPrivileges.disabled ||
invalidPagination ||
- (topicData.scheduled && !userPrivileges.view_scheduled)
+ (topicData.scheduled && !userPrivileges.view_scheduled) ||
+ (!req.uid && (topicData.cid === -1 && !uids.filter(uid => utils.isNumber(uid)).length))
) {
return next();
}