Skip to content

Commit 7213cb5

Browse files
committed
updated.
1 parent af2852c commit 7213cb5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ tp.setUserMapping({ permissions: 'allowed', groups: 'roles' });
187187

188188
* `hasPerm(user, perm, object)` - Returns true if the user has that permission on that object, otherwise false.
189189

190-
This is the heart of the system: checking permissions. It's very simply; you pass the user object, the permission descriptor (string), and the object descriptor (string). Here are a few examples:
190+
This is the heart of the system: checking permissions. It's very simply; you pass the user object, the permission
191+
descriptor (string), and the object descriptor (string). (We also support passing in the same format as you define the
192+
permissions, `'Object/perm'`.) Here are a few examples:
191193

192194
```javascript
193195
const tp = require('../dist/trivialperms');
@@ -239,6 +241,9 @@ loading.then(() =>
239241
// Batman can edit posts
240242
console.log(tp.hasPerm(batman, 'canEdit', 'Posts')); // true
241243

244+
// Supports the single string form
245+
console.log(tp.hasPerm(batman, 'Posts/canEdit')); // true
246+
242247
// Tony Start can do anything
243248
console.log(tp.hasPerm(stark, 'canEdit', 'Posts')); // true
244249
console.log(tp.hasPerm(stark, 'canGetAwayWith', 'Murder')); // true

0 commit comments

Comments
 (0)