Makes sure we don't duplicate user ACL's keys (#2651)

* Adds repro for issue #2246

* Provide fix for issue #2246

* Nit with Set to deduplicate the acl array

* remove debuging console.log
This commit is contained in:
Florent Vilmart
2016-09-09 14:43:59 -04:00
committed by GitHub
parent e8aa1ad312
commit c5fdd91aa3
3 changed files with 40 additions and 2 deletions

View File

@@ -149,8 +149,9 @@ RestQuery.prototype.getUserAndRoleACL = function() {
return Promise.resolve();
}
return this.auth.getUserRoles().then((roles) => {
roles.push(this.auth.user.id);
this.findOptions.acl = roles;
// Concat with the roles to prevent duplications on multiple calls
const aclSet = new Set([].concat(this.findOptions.acl, roles));
this.findOptions.acl = Array.from(aclSet);
return Promise.resolve();
});
};