2013-06-25 15:43:15 +04:00
|
|
|
// canThis(someUser).edit.posts([id]|[[ids]])
|
|
|
|
// canThis(someUser).edit.post(somePost|somePostId)
|
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
const models = require('../../models');
|
|
|
|
|
|
|
|
const actionsMap = require('./actions-map-cache');
|
2013-06-25 15:43:15 +04:00
|
|
|
|
2020-10-20 02:02:56 +03:00
|
|
|
const init = function init(options) {
|
2016-08-23 15:07:25 +03:00
|
|
|
options = options || {};
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
// Load all the permissions
|
2017-10-05 22:01:34 +03:00
|
|
|
return models.Permission.findAll(options)
|
|
|
|
.then(function (permissionsCollection) {
|
|
|
|
return actionsMap.init(permissionsCollection);
|
2013-06-05 07:47:11 +04:00
|
|
|
});
|
2013-06-25 15:43:15 +04:00
|
|
|
};
|
2013-06-05 07:47:11 +04:00
|
|
|
|
2017-10-05 22:01:34 +03:00
|
|
|
module.exports = {
|
2013-06-25 15:43:15 +04:00
|
|
|
init: init,
|
2017-10-05 22:01:34 +03:00
|
|
|
canThis: require('./can-this'),
|
2017-09-25 12:17:06 +03:00
|
|
|
// @TODO: Make it so that we don't need to export these
|
2017-10-05 22:01:34 +03:00
|
|
|
parseContext: require('./parse-context'),
|
|
|
|
applyPublicRules: require('./public')
|
2013-10-31 22:02:34 +04:00
|
|
|
};
|