Skip to content

FilteredAdapter should not dynamically change to ordinary Adapter #2

Description

@ulanmurzatayev

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

this.setFiltered(false);

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions