Trying to follow instructions for alanning:roles but to no avail. I’m able to create users, but the helper check {{#if isInRole ‘client’}} doesn’t recognize the user being in that role, which I am. Follow up questions would be appreciated and I’ll try and respond as soon as I’m able to. Thanks!
// fixtures.js
function createUsers() {
let users;
if (Meteor.users.find().fetch().length === 0) {
console.log('Creating users: ');
users = [
{
name: 'user_clayton',
email: 'user_clayton@example.com',
roles: ['user'],
},
{
name: 'client_clayton',
email: 'client_clayton@example.com',
roles: ['client'],
},
];
users.forEach((userData) => {
console.log(userData);
const id = Accounts.createUser({
email: userData.email,
password: 'p@ssW0rd',
profile: { name: userData.name },
});
// email verification
Meteor.users.update(
{ _id: id },
{ $set: { 'emails.0.verified': true } }
);
Roles.addUsersToRoles(id, userData.roles);
});
}
}
Meteor.startup(() => {
process.env.MONGO_URL = Meteor.settings.MONGO_URL;
createUsers();
});
// body.html
<template name="app_body">
{{> loginButtons}}
{{#if isInRole 'client'}}
<section class="app-buttons">
<ul>
<li class="js-products">
<a href="/products" class="js-products">Products</a>
</li>
<li class="js-profile">
<a href="/profile" class="js-profile">Profile</a>
</li>
<li class="js-brands">
<a href="/brands" class="js-brands">Brands</a>
</li>
</ul>
</section>
{{> yield}}
{{/if }}
</template>