mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
6760ccc8ec
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).
25 lines
680 B
JavaScript
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')
|
|
};
|