mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: handle search tag permission as well
This commit is contained in:
@@ -4549,6 +4549,8 @@ paths:
|
||||
type: boolean
|
||||
search:content:
|
||||
type: boolean
|
||||
search:tags:
|
||||
type: boolean
|
||||
required:
|
||||
- posts
|
||||
- matchCount
|
||||
|
||||
@@ -25,9 +25,12 @@ searchController.search = async function (req, res, next) {
|
||||
const userPrivileges = await utils.promiseParallel({
|
||||
'search:users': privileges.global.can('search:users', req.uid),
|
||||
'search:content': privileges.global.can('search:content', req.uid),
|
||||
'search:tags': privileges.global.can('search:tags', req.uid),
|
||||
});
|
||||
|
||||
const allowed = (req.query.in === 'users') ? userPrivileges['search:users'] : userPrivileges['search:content'];
|
||||
const allowed = (req.query.in === 'users' && userPrivileges['search:users']) ||
|
||||
(req.query.in === 'tags' && userPrivileges['search:tags']) ||
|
||||
(['titles', 'titlesposts', 'posts'].includes(req.query.in) && userPrivileges['search:content']);
|
||||
|
||||
if (!allowed) {
|
||||
return helpers.notAllowed(req, res);
|
||||
|
||||
Reference in New Issue
Block a user