connect-crew
Connect/Express middleware to validate if a user belongs to a group. Works nicely with passport.
Install
$ npm install --save connect-crew
Requirements
Usage
By default, connect-crew assumes your authentication middleware returns req.user.groups
as an Array. Check path option if you need to change it.
Single request
const express = const crew = ;const passport = ; app; app; app;
All requests
const express = const crew = ;const passport = ; appapp;
API
crew(input, [options])
input
Type: string
or array
Groups to validate.
options
path
Type: string
Default: user.groups
Groups array path inside req
object.
error
Type: object
Default: { code: 401, message: 'Unauthorized'}
Error message when user doesn't belong to a group.
Default options
crewoptions path: 'member.crew' error: code: 401 message: 'You are not welcome' ;
Develop
Inside the project folder:
npm inpm start
License
MIT © Chef's Plate