mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
refactor: change name to privileges to match other apis
This commit is contained in:
@@ -4542,12 +4542,12 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
searchDefaultSortBy:
|
searchDefaultSortBy:
|
||||||
type: string
|
type: string
|
||||||
permissions:
|
privileges:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
users:
|
search:users:
|
||||||
type: boolean
|
type: boolean
|
||||||
content:
|
search:content:
|
||||||
type: boolean
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- posts
|
- posts
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ searchController.search = async function (req, res, next) {
|
|||||||
|
|
||||||
const searchOnly = parseInt(req.query.searchOnly, 10) === 1;
|
const searchOnly = parseInt(req.query.searchOnly, 10) === 1;
|
||||||
|
|
||||||
const permissions = await utils.promiseParallel({
|
const userPrivileges = await utils.promiseParallel({
|
||||||
users: privileges.global.can('search:users', req.uid),
|
'search:users': privileges.global.can('search:users', req.uid),
|
||||||
content: privileges.global.can('search:content', req.uid),
|
'search:content': privileges.global.can('search:content', req.uid),
|
||||||
});
|
});
|
||||||
|
|
||||||
const allowed = (req.query.in === 'users') ? permissions.users : permissions.content;
|
const allowed = (req.query.in === 'users') ? userPrivileges['search:users'] : userPrivileges['search:content'];
|
||||||
|
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
return helpers.notAllowed(req, res);
|
return helpers.notAllowed(req, res);
|
||||||
@@ -84,7 +84,7 @@ searchController.search = async function (req, res, next) {
|
|||||||
searchData.title = '[[global:header.search]]';
|
searchData.title = '[[global:header.search]]';
|
||||||
|
|
||||||
searchData.searchDefaultSortBy = meta.config.searchDefaultSortBy || '';
|
searchData.searchDefaultSortBy = meta.config.searchDefaultSortBy || '';
|
||||||
searchData.permissions = permissions;
|
searchData.privileges = userPrivileges;
|
||||||
|
|
||||||
res.render('search', searchData);
|
res.render('search', searchData);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user