import { Roles } from 'meteor/alanning:roles' if(Meteor.isServer) { Meteor.publish('roles', function() { //console.log("Checking if user is in the manage role: " + Meteor.userId() + " === " + Roles.userIsInRole(this.userId, ['manage'])) if(Roles.userIsInRole(this.userId, ['manage'])) { //Meteor.roles.find({}, {fields: {name: 1}}).fetchAsync().then(roles => {console.log(roles)}) //return Meteor.roles.find({}, {fields: {name: 1}}); return Meteor.roles.find({}); } else throw new Meteor.Error(403, "Not authorized to view roles."); }); Meteor.publish("roleAssignments", function() { if(Roles.userIsInRole(this.userId, ['manage'])) { return Meteor.roleAssignment.find({}); } else throw new Meteor.Error(403, "Not authorized to view roles."); }) } let ROLE_MANAGE = "manage"; let ROLE_UPDATE = "update"; Meteor.UserRoles = {ROLE_MANAGE, ROLE_UPDATE}; // This is the collection that maps users to roles (v3 of alanning:roles). //Meteor.roleAssignment // This is where you will find the roles defained in MongoDB: //Meteor.roles Roles.createRoleAsync(ROLE_MANAGE) Roles.createRoleAsync(ROLE_UPDATE) export default Meteor.roles;