Computation of permissions seems to somehow work.

This commit is contained in:
Tomas Bures 2017-07-25 02:14:17 +03:00
parent e7bdfb7745
commit 5df444f641
12 changed files with 286 additions and 133 deletions

View file

@ -4,6 +4,7 @@ const knex = require('../lib/knex');
const hasher = require('node-object-hash')();
const { enforce, filterObject } = require('../lib/helpers');
const interoperableErrors = require('../shared/interoperable-errors');
const shares = require('./shares');
const allowedKeys = new Set(['name', 'description', 'namespace']);
@ -34,6 +35,9 @@ async function create(entity) {
}
}
// We don't have to rebuild all entity types, because no entity can be a child of the namespace at this moment.
await shares.rebuildPermissions(tx, { entityTypeId: 'namespace', entityId: id });
return id;
});
}
@ -66,6 +70,8 @@ async function updateWithConsistencyCheck(entity) {
}
await tx('namespaces').where('id', entity.id).update(filterObject(entity, allowedKeys));
await shares.rebuildPermissions(tx);
});
}