@@ -75,2 +75,7 @@ 'use strict'; | ||
if (fns.length === 0) { | ||
debug('Not authorized because there are no checks for this rule.'); | ||
return false; | ||
} | ||
var result = _.every(fns, function runner(fn) { | ||
@@ -77,0 +82,0 @@ debug('targetObject is %s', targetObject); |
{ | ||
"name": "can.js", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "micro authorization library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,4 +51,10 @@ 'use strict'; | ||
}, | ||
'humanity': { | ||
'destroy': [] | ||
} | ||
}; |
@@ -50,2 +50,9 @@ 'use strict'; | ||
tape('rule with no checks', function (t) { | ||
t.notOk(can.check(fixitures.user_john, 'destroy', 'humanity'), 'evaluates to false'); | ||
t.throws(function () { can.assert(fixitures.user_john, 'destroy', 'humanity'); }, '...or throws'); | ||
t.end(); | ||
}); | ||
tape('nonexistent rules', function (t) { | ||
@@ -52,0 +59,0 @@ t.notOk(can.check(fixitures.user_john, 'foo', 'baz'), 'evaluates to false'); |
9123
5.24%189
6.78%