Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added 2 examples: a simple one and another using a different separator
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var roles = require("roles"); | ||
|
||
roles.setSeparator("/"); | ||
|
||
roles.addApplication("myapp", [ "readonly", "readwrite" ]); | ||
roles.addProfile("guest", [ "myapp/readonly" ]); | ||
roles.addProfile("admin", [ "myapp/*" ]); | ||
|
||
if (roles.getProfile("admin").hasRoles("myapp/readwrite")) { | ||
console.log("Administrator has readwrite to myapp"); | ||
} | ||
|
||
if (!roles.getProfile("guest").hasRoles("myapp/readwrite")) { | ||
console.log("Guest does not have readwrite to myapp"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var roles = require("roles"); | ||
|
||
roles.addApplication("myapp", [ "readonly", "readwrite" ]); | ||
roles.addProfile("guest", [ "myapp.readonly" ]); | ||
roles.addProfile("admin", [ "myapp.*" ]); | ||
|
||
if (roles.getProfile("admin").hasRoles("myapp.readwrite")) { | ||
console.log("Administrator has readwrite to myapp"); | ||
} | ||
|
||
if (!roles.getProfile("guest").hasRoles("myapp.readwrite")) { | ||
console.log("Guest does not have readwrite to myapp"); | ||
} |