Stupidly Simple Account Role Verifier - Express middleware that checks if the user has the correct permission role.
npm install ssarv
For use with express.
ssarv(requiredRoles, opt)
"requiredRoles" is an array of roles allowed
"opt" is a json object. Current valid "opt" keys:
opt = {
locationOfRoles: "req.user.perm.role", //(required)
failureRedirect: "/auth/login" //(optional)
}
//express stuff here
var ssarv = require('ssarv');
app.get('/adminsAndDevsOnly', ssarv(["admin", "dev"], {
locationOfRoles: "req.user.account.role",
failureRedirect: "/auth/login"
}), function(req, res, next) {
//Do Something
});