UNPKG

we-plugin-acl

Version:

Role-based access control (RBAC) for We.js framework

21 lines (19 loc) 447 B
/** * can helper, check if user can do something * {{#can permission=permissionName roleNames=req.userRoleNames}} can {{else}} cant {{/can}} */ module.exports = function(we) { return function canHelper() { const options = arguments[arguments.length-1]; if (we.acl.canStatic(options.hash.permission, options.hash.roleNames)){ return options.fn(this); } else { return options.inverse(this); } }; };