Answer the question
In order to leave comments, you need to log in
Why is ACL(nodejs) blocking content rendering?
Hello everyone, I have my own project on angular - frontend, nodejs (express, passport, acl) - backend.
config.js
mongoose.connect(myURLtoDB, {useCreateIndex: true, useNewUrlParser: true}, function (err, db) {
.....
};
var conn = mongoose.connection;
exports.freshConnect = conn;
var db = require('../config/config.js');
var node_acl = require('acl');
var acl = new node_acl( new node_acl.mongodbBackend(db.freshConnect, 'acl_') );
router.use('/crm', checkForPermissions(), crmRouter);
function checkForPermissions() {
console.log('Я работаю')
return acl.middleware(2, getUserId);
}
function getUserId(req) {
if (req.user) {
return req.session.passport.user;
}
}
Answer the question
In order to leave comments, you need to log in
try
var db = require('../config/config.js');
var node_acl = require('acl');
var acl = new node_acl( new node_acl.mongodbBackend(db.freshConnect, 'acl_') );
router.use('/crm', checkForPermissions, crmRouter);
function checkForPermissions(req, res, next) {
console.log('Я работаю')
const userId = getUserId(req);
acl.middleware(2, userId)(req, res, next);
}
function getUserId(req) {
if (req.user) {
return req.session.passport.user;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question