Skip to content

Commit

Permalink
Merge pull request #46 from Aclify/fix-async-loops
Browse files Browse the repository at this point in the history
Fix async loops
  • Loading branch information
rimiti authored May 8, 2019
2 parents 543fa4d + 6cf13e3 commit b47420a
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 363 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@types/bluebird": "^3.5.26",
"@types/express": "^4.16.1",
"@types/jest": "^24.0.12",
"@types/lodash": "^4.14.123",
"@types/node": "^11.13.8",
"@types/lodash": "^4.14.124",
"@types/node": "^12.0.0",
"@types/redis": "^2.8.12",
"jest": "^24.7.1",
"jest": "^24.8.0",
"mongodb": "^3.2.3",
"node-mocks-http": "^1.7.5",
"prettier": "^1.17.0",
Expand Down
6 changes: 3 additions & 3 deletions src/classes/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Acl extends Common {
this.store.add(this.options.buckets.meta, 'users', userId);
this.store.add(this.options.buckets.users, userId, roles);

rolesParams.map((role: IRole) => this.store.add(this.options.buckets.roles, role, userId), this);
rolesParams.forEach((role: IRole) => this.store.add(this.options.buckets.roles, role, userId));

return this.store.end();
}
Expand Down Expand Up @@ -390,7 +390,7 @@ export class Acl extends Common {
this.store.begin();
await this.store.del(this.allowsBucket(resource), roles);

roles.forEach(async (role: IRole) => this.store.remove(this.options.buckets.resources, role, resource), this);
await Promise.all(roles.map(async (role: IRole) => this.store.remove(this.options.buckets.resources, role, resource), this));

return this.store.end();
}
Expand Down Expand Up @@ -421,7 +421,7 @@ export class Acl extends Common {
await this.store.remove(this.options.buckets.users, userId, roles);

if (Array.isArray(roles)) {
roles.forEach(async (role: IRole) => this.store.remove(this.options.buckets.roles, role, userId), this);
await Promise.all(roles.map(async (role: IRole) => this.store.remove(this.options.buckets.roles, role, userId)));
} else {
await this.store.remove(this.options.buckets.roles, roles, userId);
}
Expand Down
Loading

0 comments on commit b47420a

Please sign in to comment.