koa-roles
koa version of connect-roles
Install
$ npm install koa-roles
Usage
const Roles = ;const koa = ;const app = ; const user = async { // optional function to customise code that runs when // user fails authorisation ctxstatus = 403; var t = ctx; if t === 'json' ctxbody = message: 'Access Denied - You don\'t have permission to: ' + action ; else if t === 'html' ctx; else ctxbody = 'Access Denied - You don\'t have permission to: ' + action; }; app; // anonymous users can only access the home page// returning false stops any more rules from being// considereduser; // moderator users can access private page, but// they might not be the only ones so we don't return// false if the user isn't a moderatoruser //admin users can access all pagesuser; app;app;app; app;