fix(user.delete): remove associated ACLs

See vatesfr/xo-web#899
This commit is contained in:
Julien Fontanet 2016-09-16 15:46:16 +02:00
parent edd606563f
commit 085fb83294
2 changed files with 12 additions and 2 deletions

View File

@ -39,10 +39,9 @@ export default class {
push.apply(acls, entries)
})(acls.push)
const collection = this._acls
await Promise.all(mapToArray(
subjects,
subject => collection.get({subject}).then(pushAcls)
subject => this.getAclsForSubject(subject).then(pushAcls)
))
return acls
@ -67,6 +66,10 @@ export default class {
return this._acls.get()
}
async getAclsForSubject (subjectId) {
return this._acls.get({ subject: subjectId })
}
async getPermissionsForUser (userId) {
const [
acls,

View File

@ -100,6 +100,13 @@ export default class {
})
::pCatch(noop) // Ignore any failures.
// Remove ACLs for this user.
this._xo.getAclsForSubject(id).then(acls => {
forEach(acls, acl => {
this._xo.removeAcl(id, acl.object, acl.action)::pCatch(noop)
})
})
// Remove the user from all its groups.
forEach(user.groups, groupId => {
this.getGroup(groupId)