1.1.0 • Published 10 years ago

node-ruler v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Ruler - You CAN do more!

Ruler can help you DO more with ACL.

Just call the Judge to decide if the user can access your resource.

var Ruler = require('ruler');
var Power = require('/sample/ability'); // This file is instead the sample folder on this project.

var person = {};
person.roles = ['admin'];

var acl = new Ruler(Power);

//Promise way...
// Promise me, this user is granted!

// the question: Judge, This PERSON can CREATE an USER?
acl.judge(person, 'create', 'user')
  .then(function(access){
    if(access){
      console.log('Yes, this PERSON can CREATE an USER');
    }else{
      console.log('No, this PERSON can\'t CREATE an USER');
    }
  })
  .catch(function(err){

  });

// Callback way...
// When you return, tell me if this user is granted!

acl.judge(person, 'create', 'user', function(err, access){
  if(!err){
    if(access){
      console.log('Yes, this PERSON can CREATE an USER');
    }else{
      console.log('No, this PERSON can\'t CREATE an USER');
    }
  }
});
1.1.0

10 years ago

1.0.0

10 years ago