elasticio / casbin-mongoose-adapter

Mongoose adapter for Casbin
Apache License 2.0
15 stars 3 forks source link

Can't delete roles #6

Open fdorantesm opened 5 years ago

fdorantesm commented 5 years ago

Hi, i've used this mongoose adapter to handle rules in mongodb, I can't delete roles, what i'm doing wrong?

static async getInstance() {
    const adapter = await Adapter.newAdapter(db.uri, db.config);
    const model = `${process.env.STORAGE_PATH}/casbin/rbac.conf`;
    return casbin.newEnforcer(model, adapter);
  }

Assign roles works properly.

static async assignRole(identifier, role, domain = '*') {
    const enforcer = await Enforcer.getInstance();
    return enforcer.addRoleForUser(identifier, role, domain);
  }

deleteRoleForUser returns false

static async revokeRole(identifier, role, domain = 'admin') {
    const enforcer = await Enforcer.getInstance();
    console.log(identifier, role, domain);
    return enforcer.deleteRoleForUser(identifier, role);
  }

deleteRolesForUser returns false

static async revokeRoles(identifier) {
    const enforcer = await Enforcer.getInstance();
    return enforcer.deleteRolesForUser(identifier);
}
hsluoyz commented 5 years ago

@fdorantesm This repo seems to be dead. Use this instead: https://github.com/node-casbin/mongoose-adapter