Not able to add Roles


#1

if(Meteor.users.find().count() == 0){
var users=[
{email: "admin@home.com", username: “admin”, name: “admin”, roles:[‘admin’]},
{email: "user@home.com", username: “user”, name: “user”, roles:[‘user’]}

];
_.each(users, function(userData){
var userid = Accounts.createUser({
email: userData.email,
password: “test1”,
profile: {username: userData.username},
profile: {name: userData.name},
roles: userData.roles
});

Roles.addUsersToRoles(userid, userData.roles);

});
}

JSON From MongoDb- users:
{
"_id" : “FkTHSdp6GJBRxwqH9”,
“createdAt” : ISODate(“2015-07-05T17:20:15.624Z”),
“services” : {
“password” : {
“bcrypt” : “$2a$10$/G8L1txawsJcN1R5nMnIl.m9ksfHAfWRHBnvHeAXO2ODa4vFkBTES”
}
},
“emails” : [
{
“address” : "admin@home.com",
“verified” : false
}
],
“profile” : {
“name” : “admin”
}
}

I checked the users document, theres is no roles column and also i checked the Roles collection, no rows has been inserted.


#2

please update it to be “code” type, it cannot be read very well this way
which roles package you use?

and “roles column” in nosql :smiley:


#3

I am using alanning/meteor-roles… I made a mistake in email verification flag, got it fixed now. thanks.
I meant field instead of column…so mysql i am :slight_smile: