From 2100a03c1a9d0341dfb060d216ddc83063ddc687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 4 Jun 2020 21:31:02 -0400 Subject: [PATCH] refactor: change name to privileges to match other apis --- public/openapi/read.yaml | 6 +++--- src/controllers/search.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/openapi/read.yaml b/public/openapi/read.yaml index 8a60e0342f..2899178a16 100644 --- a/public/openapi/read.yaml +++ b/public/openapi/read.yaml @@ -4542,12 +4542,12 @@ paths: type: string searchDefaultSortBy: type: string - permissions: + privileges: type: object properties: - users: + search:users: type: boolean - content: + search:content: type: boolean required: - posts diff --git a/src/controllers/search.js b/src/controllers/search.js index 9f6aa10c68..ed0e78c0a3 100644 --- a/src/controllers/search.js +++ b/src/controllers/search.js @@ -22,12 +22,12 @@ searchController.search = async function (req, res, next) { const searchOnly = parseInt(req.query.searchOnly, 10) === 1; - const permissions = await utils.promiseParallel({ - users: privileges.global.can('search:users', req.uid), - content: privileges.global.can('search:content', req.uid), + const userPrivileges = await utils.promiseParallel({ + 'search:users': privileges.global.can('search:users', 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) { return helpers.notAllowed(req, res); @@ -84,7 +84,7 @@ searchController.search = async function (req, res, next) { searchData.title = '[[global:header.search]]'; searchData.searchDefaultSortBy = meta.config.searchDefaultSortBy || ''; - searchData.permissions = permissions; + searchData.privileges = userPrivileges; res.render('search', searchData); };