Skip to content

Commit

Permalink
added 2 examples: a simple one and another using a different separator
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Sep 23, 2011
1 parent 67c6759 commit e5f31ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/different-separator.js
@@ -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");
}
13 changes: 13 additions & 0 deletions examples/simple.js
@@ -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");
}

0 comments on commit e5f31ea

Please sign in to comment.