pawangspandey / accesscontrol-middleware

14 stars 6 forks source link

middleware is not a function #1

Closed suresh-shetiar closed 6 years ago

suresh-shetiar commented 6 years ago

.post(validate(attendanceValidation.createAttendance), // (req, res, next) => { // req.user = { // eslint-disable-line no-param-reassign // role: 'admin', // _id: '5a65d0db9226782db8aa067e' // }; // next(); // }, accesscontrol.accessControlMiddleware({ resource: 'attendance', action: 'create', checkOwnerShip: true, // optional if false or not provided will check any permission of action operands: [ { source: 'user', key: '_id' }, // means req.user._id (use to check ownership) { source: 'body', key: 'user' } // means req.params.userId (use to check ownership) ] }), attendanceController.sendAttendance);

The above written code when executed says -- _accesscontrol2.default.accessControlMiddleware is not a function.

i think there should be a provision to check the resource and action

pawangspandey commented 6 years ago

Oops, it is documentation problem. you need to use accesscontrol.accessControlMiddleware.check instead of accesscontrol.accessControlMiddleware.

will update README.MD file.