how to assign roles to users with meteor?

让人想犯罪 __ 提交于 2019-12-25 00:28:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!