1.0.3 • Published 5 years ago

roles-allowed-express v1.0.3

Weekly downloads
1
License
LGPL-3.0
Repository
github
Last release
5 years ago

Roles allowed middleware

A simple Express middleware to check roles on the request.

Usage

var express = require('express');
var roleRequired = require('role-required');

var router = express.Router();

router.use('/admin', roleRequired(["admin"], {
    errorStatus: 403,
    errorMessage: "Forbidden",
    rolesField: "roles"
}));

router.use('/user', roleRequired(["user"]));

Notes

The middleware will check that req has a string array named as specified by the rolesField option, containing any of the strings passed in the first parameter. The options object, containing status, message and rolesField, is optional and will default to 403, Forbidden and roles. The error generated is an http-error and can be dealt by http-error-express (see related modules).

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago