Skip to content

Commit

Permalink
Merge pull request #46 from Gabriel-403/fix#45
Browse files Browse the repository at this point in the history
fix: removeFilteredNamedPolicy does not respect ptype
  • Loading branch information
hsluoyz authored Jul 17, 2021
2 parents 9dddfa9 + 35d1108 commit 6eef10d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class SequelizeAdapter implements Adapter {
...fieldValues: string[]
): Promise<void> {
const line = new CasbinRule();
line.ptype = ptype;

const idx = fieldIndex + fieldValues.length;
if (fieldIndex <= 0 && 0 < idx) {
Expand Down
8 changes: 8 additions & 0 deletions test/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ test(
['data2_admin', 'data2', 'write'],
]);

await a.removeFilteredPolicy('', 'p', 0, 'alice');
e = await newEnforcer('examples/rbac_model.conf', a);
testGetPolicy(e, [
['bob', 'data2', 'write'],
['data2_admin', 'data2', 'read'],
['data2_admin', 'data2', 'write'],
]);

testGetGroupingPolicy(e, [['alice', 'data2_admin']]);

// Remove groupingPolicy from DB
Expand Down

0 comments on commit 6eef10d

Please sign in to comment.