问题
how to assign roles to users with meteor? I installed the package meteor add alanning: roles, and then I went into command prompt and typed the meteor command shell to access the meteor console server side. and i typed this code:
Var = myId Meteor.users.findOne ({username: "Elsa"}) ._ id
Roles.addUsersToRoles (myId, [ 'admin'])**
to assign the right to the admin user and Elsa in Mongolia I see no added admin roles in the collection
回答1:
If you use the package
https://github.com/alanning/meteor-roles
Please be sure that username in database is unique.
Try these inside Meteor.startup code much before in server folder, place these
var id = Meteor.users.findOne({username: "Elsa"});
Roles.addUsersToRoles(id._id, ['admin'], 'default-group');
Hope these help
来源:https://stackoverflow.com/questions/38872003/how-to-assign-roles-to-users-with-meteor