I’m using the alanning:roles package and login is working fine. However, I’m getting an unexpected behaviour, and I’m at a loss to fix it. Any ideas are welcome.
When I use
{{if isInRole 'admin' 'default_group'}} Yeah, I'm an admin {{else}} Just a non-user {{/if}}
Output: Yeah, I'm an admin
When I use
console.log( Roles.userIsInRole(Meteor.userId, ['admin'], 'default_group') )
Output: false
My users are setup like this in /server/bootstrap.js
Meteor.startup(function () {
var default_users = [
{name: "Sid Administrator", email: "admin@some.com", password: "1234", roles: ['admin']},
{name: "Jonny FieldUser", email: "field@some.com", password: "1234", roles: ['field']},
{name: "Suzie Manager", email: "manager@some.com", password: "1234", roles: ['manager']}
];
if (Meteor.users.find().count() === 0) {
_.each(default_users, function(user) {
var id;
id = Accounts.createUser({
email: user.email,
password: user.password,
profile: {
fullname: user.name
}
});
if(user.roles.length > 0) {
Roles.addUsersToRoles(id, user.roles, 'default_group');
}
});
} });