Adds count class level permission (#3814)
* Adds count class level permission * fixup! Adds count class level permission * Adds missing count property on beforeFind request object * nits
This commit is contained in:
@@ -744,6 +744,9 @@ DatabaseController.prototype.find = function(className, query, {
|
||||
const isMaster = acl === undefined;
|
||||
const aclGroup = acl || [];
|
||||
op = op || (typeof query.objectId == 'string' && Object.keys(query).length === 1 ? 'get' : 'find');
|
||||
// Count operation if counting
|
||||
op = (count === true ? 'count' : op);
|
||||
|
||||
let classExists = true;
|
||||
return this.loadSchema()
|
||||
.then(schemaController => {
|
||||
|
||||
@@ -137,7 +137,7 @@ function verifyPermissionKey(key) {
|
||||
}
|
||||
}
|
||||
|
||||
const CLPValidKeys = Object.freeze(['find', 'get', 'create', 'update', 'delete', 'addField', 'readUserFields', 'writeUserFields']);
|
||||
const CLPValidKeys = Object.freeze(['find', 'count', 'get', 'create', 'update', 'delete', 'addField', 'readUserFields', 'writeUserFields']);
|
||||
function validateCLP(perms, fields) {
|
||||
if (!perms) {
|
||||
return;
|
||||
@@ -820,7 +820,7 @@ export default class SchemaController {
|
||||
|
||||
// No matching CLP, let's check the Pointer permissions
|
||||
// And handle those later
|
||||
const permissionField = ['get', 'find'].indexOf(operation) > -1 ? 'readUserFields' : 'writeUserFields';
|
||||
const permissionField = ['get', 'find', 'count'].indexOf(operation) > -1 ? 'readUserFields' : 'writeUserFields';
|
||||
|
||||
// Reject create when write lockdown
|
||||
if (permissionField == 'writeUserFields' && operation == 'create') {
|
||||
|
||||
Reference in New Issue
Block a user