Skip to content

Commit

Permalink
fix: getImplicitPermissionsForUser works with rmMap (#272)
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>
  • Loading branch information
Zxilly authored May 19, 2021
1 parent a50ad82 commit 0d59239
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/coreEnforcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ export class CoreEnforcer {
return <RoleManager>this.rmMap.get('g');
}

/**
* getNamedRoleManager gets role manager by name.
*/
public getNamedRoleManager(name: string): RoleManager | undefined {
return this.rmMap.get(name);
}

/**
* setEffector sets the current effector.
*
Expand Down
16 changes: 9 additions & 7 deletions src/enforcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,15 @@ export class Enforcer extends ManagementEnforcer {
const q = [name];
let n: string | undefined;
while ((n = q.shift()) !== undefined) {
const role = await this.getRoleManager().getRoles(n, ...domain);
role.forEach((r) => {
if (!res.has(r)) {
res.add(r);
q.push(r);
}
});
for (const rm of this.rmMap.values()) {
const role = await rm.getRoles(n, ...domain);
role.forEach((r) => {
if (!res.has(r)) {
res.add(r);
q.push(r);
}
});
}
}

return Array.from(res);
Expand Down

0 comments on commit 0d59239

Please sign in to comment.