meteor-interface
Version:
Simple Content Management System to generate your administration interface for Meteor and React.
39 lines (27 loc) • 1.11 kB
JavaScript
;
var _configuration = _interopRequireDefault(require("../../lib/configuration"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Global Config
Meteor.publish('interface.users.all', function () {
var config = _configuration.default.get(); // Extract datas from config
var _config$roles = config.roles,
roles = _config$roles === void 0 ? [] : _config$roles;
var isAuthorized = Roles.userIsInRole(this.userId, [roles[0]]);
if (!isAuthorized) {
throw new Meteor.Error(403, "You aren't authorized to do that");
}
return Meteor.users.find();
});
Meteor.publish('interface.users.one', function (_ref) {
var userId = _ref.userId;
var config = _configuration.default.get(); // Extract datas from config
var _config$roles2 = config.roles,
roles = _config$roles2 === void 0 ? [] : _config$roles2;
var isAuthorized = Roles.userIsInRole(this.userId, [roles[0]]);
if (!isAuthorized) {
throw new Meteor.Error(403, "You aren't authorized to do that");
}
return Meteor.users.find({
_id: userId
});
});