Skip to content

Commit 1420df7

Browse files
awgeorgeacinader
authored andcommitted
Update based on @milesrichardson comment #5334 (comment)
1 parent ede262c commit 1420df7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Controllers/DatabaseController.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,14 +1432,16 @@ class DatabaseController {
14321432
)
14331433
return null;
14341434

1435-
let protectedKeys;
1436-
[...(auth.userRoles || []), '*'].forEach(role => {
1437-
// If you are in multiple groups assign the role with the least protectedKeys.
1438-
// Technically this could fail if multiple roles protect different fields and produce the same count.
1439-
// But we have no way of knowing the role hierarchy here.
1435+
let protectedKeys = Object.values(protectedFields).reduce(
1436+
(acc, val) => acc.concat(val),
1437+
[]
1438+
); //.flat();
1439+
[...(auth.userRoles || [])].forEach(role => {
14401440
const fields = protectedFields[role];
1441-
if (fields && (!protectedKeys || fields.length < protectedKeys.length)) {
1442-
protectedKeys = fields;
1441+
if (fields) {
1442+
protectedKeys = protectedKeys.filter(
1443+
value => -1 !== fields.indexOf(value)
1444+
);
14431445
}
14441446
});
14451447

0 commit comments

Comments
 (0)