Ghost/core/server/permissions/index.js
Hannah Wolfe 6760ccc8ec Permissions: minor refactors (#9104)
refs #9043

- Cleanups / refactors to make the code more manageable
- Move remaining code out of index.js 
   - Only "init" function is left. Actions map cache and init function is based heavily on the settings cache module
- refactor the odd way of exporting
   - This was cleaned up naturally by moving the actionsMap object out
- rename "effective" -> "providers"
  - "Providers" provide permissions for different things that can have permissions (users, apps, in future clients).
2017-10-05 21:01:34 +02:00

25 lines
680 B
JavaScript

// canThis(someUser).edit.posts([id]|[[ids]])
// canThis(someUser).edit.post(somePost|somePostId)
var models = require('../models'),
actionsMap = require('./actions-map-cache'),
init;
init = function init(options) {
options = options || {};
// Load all the permissions
return models.Permission.findAll(options)
.then(function (permissionsCollection) {
return actionsMap.init(permissionsCollection);
});
};
module.exports = {
init: init,
canThis: require('./can-this'),
// @TODO: Make it so that we don't need to export these
parseContext: require('./parse-context'),
applyPublicRules: require('./public')
};