Skip to content

Commit

Permalink
fix: getImplicitPermissionsForUser missing domain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nodece committed Jan 14, 2020
1 parent 968372c commit 584624c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/enforcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,16 @@ export class Enforcer extends ManagementEnforcer {
* getPermissionsForUser("alice") can only get: [["alice", "data2", "read"]].
* But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
*/
public async getImplicitPermissionsForUser(user: string): Promise<string[][]> {
const roles = [user, ...(await this.getImplicitRolesForUser(user))];
public async getImplicitPermissionsForUser(user: string, ...domain: string[]): Promise<string[][]> {
const roles = [user, ...(await this.getImplicitRolesForUser(user, ...domain))];
const res: string[][] = [];
const withDomain = domain && domain.length !== 0;
roles.forEach(n => {
res.push(...this.getPermissionsForUser(n));
if (withDomain) {
res.push(...this.getFilteredPolicy(0, n, ...domain));
} else {
res.push(...this.getPermissionsForUser(n));
}
});
return res;
}
Expand Down

0 comments on commit 584624c

Please sign in to comment.