1
People I am trying to apply Authorization (ACL) using the plugin npm "node_acl" in a Node.js application with express, I am trying to implement as explained in the documentation.. however I am having difficulties to apply this in practice.. I have the following code in a projectController.js file
import express from 'express';
import authMiddleware from '../middlewares/auth';
import mongoose from '../../database';
const router = express.Router();
let acl = require('acl');
acl = new acl(new acl.mongodbBackend(mongoose.connection.db, 'acl_'));
acl.allow("admin", "/projects", "*");
router.use(authMiddleware);
router.use(acl.middleware());
router.get('/', (req, res) => {
res.send({
ok: true,
user: req.userId
})
});
export default (app) => app.use('/projects', router);
I was wrong about something?
Thank you!