Skip to content

Commit 6e4f876

Browse files
committed
fix: remove use spread operator with await in array
1 parent 9d612ef commit 6e4f876

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/enforcer.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ export class Enforcer extends ManagementEnforcer {
288288
res.push(...roles);
289289

290290
for (const n of roles) {
291-
res.push(...(await this.getImplicitRolesForUser(n, ...domain)));
291+
const role = await this.getImplicitRolesForUser(n, ...domain);
292+
res.push(...role);
292293
}
293294

294295
return res;
@@ -306,15 +307,18 @@ export class Enforcer extends ManagementEnforcer {
306307
* But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
307308
*/
308309
public async getImplicitPermissionsForUser(user: string, ...domain: string[]): Promise<string[][]> {
309-
const roles = [user, ...(await this.getImplicitRolesForUser(user, ...domain))];
310+
const roles = await this.getImplicitRolesForUser(user, ...domain);
311+
roles.unshift(user);
310312
const res: string[][] = [];
311313
const withDomain = domain && domain.length !== 0;
312314

313315
for (const n of roles) {
314316
if (withDomain) {
315-
res.push(...(await this.getFilteredPolicy(0, n, ...domain)));
317+
const p = await this.getFilteredPolicy(0, n, ...domain);
318+
res.push(...p);
316319
} else {
317-
res.push(...(await this.getPermissionsForUser(n)));
320+
const p = await this.getPermissionsForUser(n);
321+
res.push(...p);
318322
}
319323
}
320324

src/rbac/defaultRoleManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class DefaultRoleManager implements RoleManager {
204204
* printRoles prints all the roles to log.
205205
*/
206206
public async printRoles(): Promise<void> {
207-
[...this.allRoles.values()].map(n => {
207+
[...this.allRoles.values()].forEach(n => {
208208
logPrint(n.toString());
209209
});
210210
}

0 commit comments

Comments
 (0)