Allow ACLs for methods/relations

This commit is contained in:
Raymond Feng 2013-11-15 10:08:49 -08:00
parent 8381b05da1
commit 44dfe34647
1 changed files with 6 additions and 2 deletions

View File

@ -165,7 +165,7 @@ ACL.checkPermission = function (principalType, principalId, model, property, acc
modelClass.settings.acls.forEach(function(acl) {
staticACLs.push({
model: model,
property: ACL.ALL,
property: acl.property || ACL.ALL,
principalType: acl.principalType,
principalId: acl.principalId, // TODO: Should it be a name?
accessType: acl.accessType,
@ -173,7 +173,11 @@ ACL.checkPermission = function (principalType, principalId, model, property, acc
});
});
}
var prop = modelClass && modelClass.definition.properties[property];
var prop = modelClass &&
(modelClass.definition.properties[property] // regular property
|| (modelClass._scopeMeta && modelClass._scopeMeta[property]) // relation/scope
|| modelClass[property] // static method
|| modelClass.prototype[property]); // prototype method
if(prop && prop.acls) {
prop.acls.forEach(function(acl) {
staticACLs.push({