2013-06-25 15:43:15 +04:00
|
|
|
// canThis(someUser).edit.posts([id]|[[ids]])
|
|
|
|
// canThis(someUser).edit.post(somePost|somePostId)
|
|
|
|
|
2017-12-14 05:01:23 +03:00
|
|
|
var models = require('../../models'),
|
2017-10-05 22:01:34 +03:00
|
|
|
actionsMap = require('./actions-map-cache'),
|
|
|
|
init;
|
2013-06-25 15:43:15 +04:00
|
|
|
|
2017-10-05 22:01:34 +03:00
|
|
|
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
|
|
|
};
|