Skip to content

Node.js based forum software built for the modern web

fix(categories): hide disabled categories from non-admins in get

Julian Lam88847e64fb09
diff --git a/src/api/categories.js b/src/api/categories.js
index 86e7833259..1cbdf1ddd7 100644
--- a/src/api/categories.js
+++ b/src/api/categories.js
@@ -36,11 +36,12 @@ categoriesAPI.list = async (caller) => {
};
categoriesAPI.get = async function (caller, data) {
- const [userPrivileges, category] = await Promise.all([
+ const [userPrivileges, category, isAdmin] = await Promise.all([
privileges.categories.get(data.cid, caller.uid),
categories.getCategoryData(data.cid),
+ user.isAdministrator(caller.uid),
]);
- if (!category || !userPrivileges.read) {
+ if (!category || !userPrivileges.read || (category.disabled && !isAdmin)) {
return null;
}