diff --git a/src/transform.js b/src/transform.js index 6c1b85ec32..e3326cadbf 100644 --- a/src/transform.js +++ b/src/transform.js @@ -227,7 +227,7 @@ function transformUpdate(schema, className, restUpdate) { var mongoUpdate = {}; var acl = transformACL(restUpdate); - if (acl._rperm || acl._wperm) { + if (acl._rperm || acl._wperm || acl._acl) { mongoUpdate['$set'] = {}; if (acl._rperm) { mongoUpdate['$set']['_rperm'] = acl._rperm; @@ -235,6 +235,9 @@ function transformUpdate(schema, className, restUpdate) { if (acl._wperm) { mongoUpdate['$set']['_wperm'] = acl._wperm; } + if (acl._acl) { + mongoUpdate['$set']['_acl'] = acl._acl; + } } for (var restKey in restUpdate) { @@ -284,16 +287,22 @@ function transformACL(restObject) { var acl = restObject['ACL']; var rperm = []; var wperm = []; + var _acl = {}; for (var entry in acl) { if (acl[entry].read) { rperm.push(entry); + _acl[entry] = _acl[entry] || {}; + _acl[entry]['r'] = true; } if (acl[entry].write) { wperm.push(entry); + _acl[entry] = _acl[entry] || {}; + _acl[entry]['w'] = true; } } output._rperm = rperm; output._wperm = wperm; + output._acl = _acl; delete restObject.ACL; return output; }