fix: #12183, remove ensureLoggedIn middleware

from category routes
add privilege check to getTopicCount
This commit is contained in:
Barış Soner Uşaklı
2023-11-24 17:05:36 -05:00
parent 22932bdb40
commit 0a4f3c8a56
2 changed files with 8 additions and 4 deletions

View File

@@ -80,6 +80,10 @@ categoriesAPI.delete = async function (caller, { cid }) {
};
categoriesAPI.getTopicCount = async (caller, { cid }) => {
const allowed = await privileges.categories.can('find', cid, caller.uid);
if (!allowed) {
throw new Error('[[error:no-privileges]]');
}
const count = await categories.getCategoryField(cid, 'topic_count');
return { count };
};