Skip to content

Commit

Permalink
Add domain paramter for getImplicitPermissionsForUser
Browse files Browse the repository at this point in the history
  • Loading branch information
nodece committed Jan 14, 2020
1 parent e915afc commit c1bfbf5
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 @@ -294,11 +294,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 getImplicitPermissionsForUser(user: string) {
const roles = [user, ...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 c1bfbf5

Please sign in to comment.