{"_id":"egg-userrole","_rev":"1213593","name":"egg-userrole","description":"user role plugin for egg","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"time":{"modified":"2021-10-13T05:46:50.000Z","created":"2016-05-26T09:09:40.587Z","2.1.0":"2018-12-14T08:49:55.621Z","2.0.0":"2017-11-23T10:09:41.540Z","1.1.2":"2017-06-06T15:48:59.126Z","1.1.1":"2017-01-25T03:25:08.541Z","1.1.0":"2017-01-22T10:31:45.187Z","1.0.0":"2016-11-03T03:18:54.010Z","0.1.0":"2016-08-16T14:47:37.473Z","0.0.3":"2016-07-18T12:24:08.437Z","0.0.2":"2016-07-17T14:57:58.002Z","0.0.1":"2016-05-26T09:09:40.587Z"},"users":{},"author":{"name":"TZ","email":"atian25@qq.com"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"versions":{"2.1.0":{"name":"egg-userrole","version":"2.1.0","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"dependencies":{"koa-roles":"^2.0.0"},"devDependencies":{"autod":"^3.0.1","egg":"^2.0.0","egg-bin":"^4.3.5","egg-ci":"^1.10.0","egg-mock":"^3.13.1","eslint":"^4.11.0","eslint-config-egg":"^5.1.1"},"engines":{"node":">=8.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"8, 10"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"22c3208cb45728e8ca90e1c31a3eebb7d000b7a8","_id":"egg-userrole@2.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"wanghx","email":"whxaxes@gmail.com"},"dist":{"shasum":"36bd32b6e53fc3543cfd9f4a0ded14c4f948b54f","size":3191,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-2.1.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-userrole_2.1.0_1544777395507_0.5779311320053058"},"_hasShrinkwrap":false,"publish_time":1544777395621,"_cnpm_publish_time":1544777395621},"2.0.0":{"name":"egg-userrole","version":"2.0.0","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"files":["config","app.js"],"dependencies":{"koa-roles":"^2.0.0"},"devDependencies":{"autod":"^3.0.1","egg":"^2.0.0","egg-bin":"^4.3.5","egg-ci":"^1.8.0","egg-mock":"^3.13.1","eslint":"^4.11.0","eslint-config-egg":"^5.1.1"},"engines":{"node":">=8.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"8, 9"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"af185efade5bf626c3f170b1d647296878e16b48","_id":"egg-userrole@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.4.0","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"5347b3fc0a3f11c50fec219c135c6f7072bccf80","size":3187,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-2.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-userrole-2.0.0.tgz_1511431781433_0.7576571542304009"},"directories":{},"publish_time":1511431781540,"_hasShrinkwrap":false,"_cnpm_publish_time":1511431781540},"1.1.2":{"name":"egg-userrole","version":"1.1.2","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"files":["config","app.js"],"dependencies":{"koa-roles":"^1.0.3"},"devDependencies":{"autod":"^2.8.0","egg":"^1.4.0","egg-bin":"^3.4.2","egg-ci":"^1.7.0","egg-mock":"^3.7.1","eslint":"^3.19.0","eslint-config-egg":"^4.2.0"},"engines":{"node":">=6.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"6, 7"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"7517e28c46a32574fa4088dc20bd436aa30c3045","_id":"egg-userrole@1.1.2","_npmVersion":"5.0.0","_nodeVersion":"8.0.0","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"dist":{"shasum":"0bf3860653ce77e5afb3bd0fcf101c20ed47508a","size":3035,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-1.1.2.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-userrole-1.1.2.tgz_1496764138589_0.8595680776052177"},"directories":{},"publish_time":1496764139126,"_hasShrinkwrap":false,"_cnpm_publish_time":1496764139126},"1.1.1":{"name":"egg-userrole","version":"1.1.1","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"files":["config","app.js"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"^2.7.1","egg":"~0.8.0","egg-bin":"^1.6.0","egg-ci":"^1.0.3","egg-mock":"^1.1.0","eslint":"^3.9.1","eslint-config-egg":"^3.1.0","supertest":"^2.0.1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"6, 7"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"399826f5be50775147be23b239ed2cbda74443b0","_id":"egg-userrole@1.1.1","_shasum":"9f30bf79fc546503094215add14dd81e2303ac60","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"dist":{"shasum":"9f30bf79fc546503094215add14dd81e2303ac60","size":3014,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-1.1.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-userrole-1.1.1.tgz_1485314708295_0.42171281203627586"},"directories":{},"publish_time":1485314708541,"_cnpm_publish_time":1485314708541,"_hasShrinkwrap":false},"1.1.0":{"name":"egg-userrole","version":"1.1.0","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"files":["config","app.js"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"^2.7.1","egg":"~0.8.0","egg-bin":"^1.6.0","egg-ci":"^1.0.3","egg-mock":"^1.1.0","eslint":"^3.9.1","eslint-config-egg":"^3.1.0","supertest":"^2.0.1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"6, 7"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"6c2f94df6ccd7272a1da176c0cef4c21e4ffa717","_id":"egg-userrole@1.1.0","_shasum":"6ba6976c67773638b114119cdbfed50b8e845311","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.9.1","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"6ba6976c67773638b114119cdbfed50b8e845311","size":2989,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-1.1.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/egg-userrole-1.1.0.tgz_1485081103367_0.26333185099065304"},"directories":{},"publish_time":1485081105187,"_cnpm_publish_time":1485081105187,"_hasShrinkwrap":false},"1.0.0":{"name":"egg-userrole","version":"1.0.0","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"^2.7.1","egg":"*","egg-bin":"^1.6.0","egg-ci":"^1.0.3","egg-mock":"^1.1.0","eslint":"^3.9.1","eslint-config-egg":"^3.1.0","supertest":"^2.0.1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint .","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"4, 6, 7"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"1885e13ec79b6830d801ce92ba8bc7d409dea09e","_id":"egg-userrole@1.0.0","_shasum":"bf94b37bfa4502dc356ea11949f9638731803f7b","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.0","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"bf94b37bfa4502dc356ea11949f9638731803f7b","size":11989,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-1.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/egg-userrole-1.0.0.tgz_1478143132056_0.573493585921824"},"directories":{},"publish_time":1478143134010,"_cnpm_publish_time":1478143134010,"_hasShrinkwrap":false},"0.1.0":{"name":"egg-userrole","version":"0.1.0","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"2","egg":"test","egg-bin":"1","egg-ci":"1","egg-mock":"~0.0.1","eslint":"3","eslint-config-egg":"3","should":"8","supertest":"1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint --ext js . --fix","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"4, 6"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"a6b7b6851b2e234aebef6517d2620bced5666d05","_id":"egg-userrole@0.1.0","_shasum":"ff045ebf8c7e231c202d1f0b92e04a3a9a2ae166","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"ff045ebf8c7e231c202d1f0b92e04a3a9a2ae166","size":4624,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-0.1.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-userrole-0.1.0.tgz_1471358854950_0.9928999743424356"},"directories":{},"publish_time":1471358857473,"_cnpm_publish_time":1471358857473,"_hasShrinkwrap":false},"0.0.3":{"name":"egg-userrole","version":"0.0.3","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"2","egg":"^0.0.4","egg-bin":"1","egg-ci":"1","egg-mock":"^0.0.1","eslint":"3","eslint-config-egg":"3","should":"8","supertest":"1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint --ext js . --fix","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"4, 6"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"4bdd078ebcf6c8bf42b5c3f49024dfd6defebf76","_id":"egg-userrole@0.0.3","_shasum":"e577b32d4be0d1cfa55972eb94bb68f62a19c149","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"e577b32d4be0d1cfa55972eb94bb68f62a19c149","size":12712,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-0.0.3.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-userrole-0.0.3.tgz_1468844646337_0.00398341054096818"},"directories":{},"publish_time":1468844648437,"_cnpm_publish_time":1468844648437,"_hasShrinkwrap":false},"0.0.2":{"name":"egg-userrole","version":"0.0.2","description":"user role plugin for egg","eggPlugin":{"name":"userrole"},"keywords":["egg","plugin","userrole"],"dependencies":{"koa-roles":"^1.0.2"},"devDependencies":{"autod":"2","egg":"^0.0.4","egg-bin":"1","egg-ci":"1","egg-mock":"^0.0.1","eslint":"3","eslint-config-egg":"3","should":"8","supertest":"1"},"engines":{"node":">=4.0.0"},"scripts":{"test":"npm run lint && npm run test-local","test-local":"egg-bin test","cov":"egg-bin cov","lint":"eslint --ext js . --fix","ci":"npm run lint && npm run cov","autod":"autod"},"ci":{"version":"4, 6"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg/issues"},"homepage":"https://github.com/eggjs/egg-userrole#readme","author":{"name":"TZ","email":"atian25@qq.com"},"license":"MIT","gitHead":"70be1564e17d1d7ae32cfa6d50828b3d5a414541","_id":"egg-userrole@0.0.2","_shasum":"244bd0fc54d662fd3ca317f2aadb0dbb5dd81d0f","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"244bd0fc54d662fd3ca317f2aadb0dbb5dd81d0f","size":12453,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-0.0.2.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-userrole-0.0.2.tgz_1468767477755_0.6974917994812131"},"directories":{},"publish_time":1468767478002,"_cnpm_publish_time":1468767478002,"_hasShrinkwrap":false},"0.0.1":{"name":"egg-userrole","version":"0.0.1","description":"egg plugin <egg-userrole>","keywords":["egg","eggjs","egg-plugin"],"homepage":"https://github.com/eggjs/egg-userrole","license":"MIT","author":{"name":"eggjs"},"contributors":[{"name":"TZ","email":"atian25@qq.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"fengmk2","email":"m@fengmk2.com"},{"name":"dead-horse","email":"heyiyu.deadhorse@gmail.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/egg-userrole.git"},"bugs":{"url":"https://github.com/eggjs/egg-userrole/issues"},"_id":"egg-userrole@0.0.1","scripts":{},"_shasum":"35f23bcdf0fb7120a2372e520c36ff3cd8184822","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"35f23bcdf0fb7120a2372e520c36ff3cd8184822","size":428,"noattachment":false,"key":"/egg-userrole/-/egg-userrole-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userrole/download/egg-userrole-0.0.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},{"name":"wanghx","email":"851094531@qq.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-userrole-0.0.1.tgz_1464253780040_0.35513931466266513"},"directories":{},"publish_time":1464253780587,"_cnpm_publish_time":1464253780587,"_hasShrinkwrap":false}},"readme":"# egg-userrole\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-userrole.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-userrole\n[travis-image]: https://img.shields.io/travis/eggjs/egg-userrole.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/egg-userrole\n[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-userrole.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/egg-userrole?branch=master\n[david-image]: https://img.shields.io/david/eggjs/egg-userrole.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-userrole\n[snyk-image]: https://snyk.io/test/npm/egg-userrole/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-userrole\n[download-image]: https://img.shields.io/npm/dm/egg-userrole.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-userrole\n\nProvide dynamic roles based authorisation. Use [koa-roles](https://github.com/koajs/koa-roles).\n\n## Install\n\n```bash\n$ npm i egg-userrole --save\n```\n\n## Usage\n```javascript\n// {app_root}/config/plugin.js\nexports.userrole = {\n  package: 'egg-userrole',\n};\n```\n\n> Recommend to use along with custom `userservice` plugin (which provide `ctx.user`).\n>\n> see [`egg-userservice`](https://github.com/eggjs/egg-userservice) for more info.\n\n### Build-in\n\n`Roles` build-in `failureHandler`:\n\n```javascript\nfunction failureHandler(ctx, action) {\n  const message = 'Forbidden, required role: ' + action;\n  if (ctx.acceptJSON) {\n    ctx.body = {\n      message: message,\n      stat: 'deny',\n    };\n  } else {\n    ctx.status = 403;\n    ctx.body = message;\n  }\n};\n```\n\nBuild-in `user` role define:\n\n```javascript\napp.role.use('user', ctx => !!ctx.user);\n```\n\n### How to custom `failureHandler`\n\nDefine `app.role.failureHandler(action)` method in `config/role.js`\n\n- `app/extend/context.js`\n\n```javascript\n// {app_root}/config/role.js or {framework_root}/config/role.js\nmodule.exports = app => {\n  app.role.failureHandler = function(ctx, action) {\n    if (ctx.acceptJSON) {\n      ctx.body = { target: loginURL, stat: 'deny' };\n    } else {\n      ctx.realStatus = 200;\n      ctx.redirect(loginURL);\n    }\n  };\n}\n```\n\n### How to custom role\n\n```javascript\n// {app_root}/config/role.js or {framework_root}/config/role.js\nmodule.exports = function(app) {\n  app.role.use('admin', ctx => {\n    return ctx.user && ctx.user.isAdmin;\n  });\n\n  app.role.use('can write', async ctx => {\n    const post = await ctx.service.post.fetch(ctx.request.body.id);\n    return ctx.user.name === post.author;\n  });\n};\n```\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](https://github.com/eggjs/egg-userrole/blob/master/LICENSE)\n","_attachments":{},"homepage":"https://github.com/eggjs/egg-userrole#readme","bugs":{"url":"https://github.com/eggjs/egg/issues"},"license":"MIT"}