When creating a FilteredAdapter with MongooseAdapter.newFilteredAdapter(config.db) it is expected to stay as FilteredAdapter. However current behaviour is that it changes dynamically during execution
Now the problem is that when a filtered adapter is first created casbin internally calls loadPolicy(model)
|
async loadPolicy (model) { |
which switches it back to an ordinary adapter. Then if a user calls enforcer.loadFilteredPolicy() casbin throws an error, as it does not recognize the adapter to be filtered anymore
https://github.com/casbin/node-casbin/blob/40dd90a6dd7a023746bc3c15593d96d802c612ab/src/coreEnforcer.ts#L164
I think loadPolicy() should work without changing the adapter type.
When creating a
FilteredAdapterwithMongooseAdapter.newFilteredAdapter(config.db)it is expected to stay as FilteredAdapter. However current behaviour is that it changes dynamically during executioncasbin-mongoose-adapter/src/adapter.js
Line 141 in 4a87b7a
Now the problem is that when a filtered adapter is first created casbin internally calls
loadPolicy(model)casbin-mongoose-adapter/src/adapter.js
Line 126 in 4a87b7a
which switches it back to an ordinary adapter. Then if a user calls
enforcer.loadFilteredPolicy()casbin throws an error, as it does not recognize the adapter to be filtered anymorehttps://github.com/casbin/node-casbin/blob/40dd90a6dd7a023746bc3c15593d96d802c612ab/src/coreEnforcer.ts#L164
I think
loadPolicy()should work without changing the adapter type.