Update based on @milesrichardson comment https://github.com/parse-community/parse-server/pull/5334#discussion_r252693409
This commit is contained in:
@@ -1432,14 +1432,16 @@ class DatabaseController {
|
|||||||
)
|
)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
let protectedKeys;
|
let protectedKeys = Object.values(protectedFields).reduce(
|
||||||
[...(auth.userRoles || []), '*'].forEach(role => {
|
(acc, val) => acc.concat(val),
|
||||||
// If you are in multiple groups assign the role with the least protectedKeys.
|
[]
|
||||||
// Technically this could fail if multiple roles protect different fields and produce the same count.
|
); //.flat();
|
||||||
// But we have no way of knowing the role hierarchy here.
|
[...(auth.userRoles || [])].forEach(role => {
|
||||||
const fields = protectedFields[role];
|
const fields = protectedFields[role];
|
||||||
if (fields && (!protectedKeys || fields.length < protectedKeys.length)) {
|
if (fields) {
|
||||||
protectedKeys = fields;
|
protectedKeys = protectedKeys.filter(
|
||||||
|
value => -1 !== fields.indexOf(value)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user