You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, loving your work! I am however running into an issue with the permission.filter() function. It seems ES6's native implementation of filter() is called when a Permission object is passed through the app with res.locals.permission. Which means that if I try to do this: res.json(res.locals.permission.filter(req.user)); it returns an empty object.
My models are defined as .readOwn('user', [ 'name', 'email', 'phone' ]), and according to the documentation I should expect just the name, email and phone as a response.
The text was updated successfully, but these errors were encountered:
Have the same problem, however I'm just passing the filter function forward by binding the permission object. req.filterFn = permission.filter.bind(permission);
I've run into a similar issue using Mongoose Documents, where permission.filter(user) returned empty objects. My current workaround is converting the document to an object first via permission.filter(user.toObject()).
Yep, that's because res.locals serializes data, it's not meant to hold instances. You can pass them across middlewares using the req object, like req.permissions = [/* ... */] and there you'd be able to access all its methods.
Though, AccessControl exposes the filter method on its instance as well (ac.filter()), so maybe there's no need to access it from the permission.
Hi there, loving your work! I am however running into an issue with the
permission.filter()
function. It seems ES6's native implementation of filter() is called when aPermission
object is passed through the app withres.locals.permission
. Which means that if I try to do this:res.json(res.locals.permission.filter(req.user));
it returns an empty object.My models are defined as
.readOwn('user', [ 'name', 'email', 'phone' ])
, and according to the documentation I should expect just the name, email and phone as a response.The text was updated successfully, but these errors were encountered: