api/services/PermissionService.js
function(options) {
    var findRole = options.role ? Role.findOne({
      name: options.role
    }) : null;
    var findUser = options.user ? User.findOne({
      username: options.user
    }) : null;
    var ok = Promise.all([findRole, findUser, Model.findOne({
      name: options.model
    })]);

    ok = ok.then(([ role, user, model ]) => {

      var query = {
        model: model.id,
        action: options.action,
        relation: options.relation
      };

      if (role && role.id) {
        query.role = role.id;
      } else if (user && user.id) {
        query.user = user.id;
      } else {
        return Promise.reject(new Error('You must provide either a user or role to revoke the permission from'));
      }

      return Permission.destroy(query);
    });

    return ok;
  }
function(options) {
    var findRole = options.role ? Role.findOne({
      name: options.role
    }) : null;
    var findUser = options.user ? User.findOne({
      username: options.user
    }) : null;
    var ok = Promise.all([findRole, findUser, Model.findOne({
      name: options.model
    })]);

    ok = ok.then(([ role, user, model ]) => {

      var query = {
        model: model.id,
        action: options.action,
        relation: options.relation
      };

      if (role && role.id) {
        query.role = role.id;
      } else if (user && user.id) {
        query.user = user.id;
      } else {
        return Promise.reject(new Error('You must provide either a user or role to revoke the permission from'));
      }

      return Permission.destroy(query);
    });

    return ok;
  }
function ( options ) { var findRole = options . role ? Role . findOne ( { name : options . role } ) : null ; var findUser = options . user ? User . findOne ( { username : options . user } ) : null ; var ok = Promise . all ( [ findRole , findUser , Model . findOne ( { name : options . model } ) ] ) ; ok = ok . then ( ( [ role , user , model ] ) => { var query = { model : model . id , action : options . action , relation : options . relation } ; if ( role && role . id ) { query . role = role . id ; } else if ( user && user . id ) { query . user = user . id ; } else { return Promise . reject ( new Error ( 'You must provide either a user or role to revoke the permission from' ) ) ; } return Permission . destroy ( query ) ; } ) ; return ok ; }
revoke permission from role
@param options
@param options.role {string} - the name of the role related to the permission.  This, or options.user should be set, but not both.
@param options.user {string} - the name of the user related to the permission.  This, or options.role should be set, but not both.
@param options.model {string} - the name of the model for the permission
@param options.action {string} - the name of the action for the permission
@param options.relation {string} - the type of the relation (owner or role)
revoke permission from role