UNPKG

@incdevco/framework

Version:
34 lines (18 loc) 550 B
function Rule(role, assertion) { 'use strict'; this.assertion = assertion; this.role = role; } Rule.prototype.isAllowed = function (event, resource, privilege, context) { 'use strict'; if (this.role === undefined || event.roles.indexOf(this.role) >= 0) { if (this.assertion) { return this.assertion(event, resource, privilege, context); } else { return Promise.resolve(true); } } else { return Promise.reject(false); } }; module.exports = Rule;