Skip to content

Commit 3fd75e9

Browse files
committed
Updated check because of bug.
1 parent 7213cb5 commit 3fd75e9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/trivialperms.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const find = require('lodash/find');
99
const some = require('lodash/some');
1010
const includes = require('lodash/includes');
1111
const isFunction = require('lodash/isFunction');
12+
const isUndefined = require('lodash/isUndefined');
1213

1314
const Promise = require('bluebird');
1415
const TPGroup = require('./group');
@@ -20,7 +21,8 @@ const _ = {
2021
find,
2122
some,
2223
includes,
23-
isFunction
24+
isFunction,
25+
isUndefined
2426
};
2527

2628
const mapping = {permissions: 'permissions', groups: 'groups'};
@@ -97,7 +99,7 @@ class TPManager
9799

98100
hasPerm(user, perm, obj)
99101
{
100-
if(arguments.length === 2)
102+
if(_.isUndefined(obj))
101103
{
102104
const parts = perm.split('/');
103105
obj = parts[0];

test/trivialperms.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ describe('Permissions', () =>
188188
{
189189
it('can take the `Object/perm` form', () =>
190190
{
191-
expect(tp.hasPerm(stark, 'Posts/canEdit')).to.equal(true);
191+
expect(tp.hasPerm(leo, 'Posts/canView')).to.equal(true);
192+
expect(tp.hasPerm(leo, 'Posts/canEdit')).to.equal(false);
192193
});
193194
});
194195
});

0 commit comments

Comments
 (0)