express-checkrole
v1.0.3
Published
It is a custom middleware that helps to check user role on http requests
Downloads
1
Readme
express-checkrole
It is an Express dependant middleware i.e you must have express installed in your project
Someone can use this middleware if you want to restrict a user to access specific resources(route) on the network
Installation
npm i express
npm install express-checkrole
How to Use
app.js
const checkrole = require('express-checkrole');
app.use(checkrole(['<ROLE_NAME>'],<FLAG>,'<ROUTE_NAME>'));
// MANDATORY: suppose ROLE_NAME is ['admin','writer']. It means only if HTTP endpoint has querystring role as '?/role=admin' OR '?/role=writer' then only the user can access the particular resource.
// OPTIONAL: FLAG is type of Boolean, by default it FALSE. Functioality of this flag is like if flag is true then it will be redirected the user to root route i.e '/'
// OPTIONAL: pass a specific ROUTE name to redirect the user to a specific route e.g. '/foo'
All the best!Happy Coding! :+1: :beers: