Open silpil opened 6 years ago
@smilemoreall I have set up a sample app and it seems to work fine. Would you mind sharing your code snippets and how this bug can be reproduced
@nyambati Ok, for the test I use this boilerplate (https://github.com/sahat/hackathon-starter)
I was import express-acl into the app.js
const acl = require('express-acl');
Then I added config with roleSearchPath
acl.config({ filename: 'nacl.json', roleSearchPath: 'user.role' });
After then I called app.use(acl.authorize);
Same I added user role in database for the user, in this way req.user.role can get 'user'
Did you got any solution?
Did you got any solution?
nope
@smilemoreall Do you mind if we can sync on your issue. I think we may be able to get a solution that way.
I have got the same error. Problem is that objectPath.get
searches only within direct properties of object. To support shallow (hidden, inherited) properties, objectPath must be created with withInheritedProps
.
const objectPath = require('object-path').withInheritedProps;
I use passport in express, which create req.user
property, but I'm not javascript experienced user, so I don't know if the solution is to use withInheritedProps
or use another solution to make req.user properties as own.
Hello!
I set roleSearchPath but this config is doesn't work.
acl.config({ filename: 'nacl.json', roleSearchPath: 'user.role' });
//express-acl/lib/common.js
objectPath.get(req, searchPath) //undefined
But
searchPath
set is correct'user.role'
Example req.user:
{ "profile": { "gender": "", "location": "", "name": "", "website": "" }, "tokens": [], "things": [], "_id": "", "email": "", "password": "", "role": "user" }