Roles not being recognized

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: '',
				roles: ['user'],
				name: 'client_clayton',
				email: '',
				roles: ['client'],

		users.forEach((userData) => {
			const id = Accounts.createUser({
				password: 'p@ssW0rd',
				profile: { name: },

			// email verification
				{ _id: id },
				{ $set: { 'emails.0.verified': true } }

			Roles.addUsersToRoles(id, userData.roles);

Meteor.startup(() => {
	process.env.MONGO_URL = Meteor.settings.MONGO_URL;
// body.html
<template name="app_body">
	{{> loginButtons}}
		{{#if isInRole 'client'}}
			<section class="app-buttons">
					<li class="js-products">
						<a href="/products" class="js-products">Products</a>
					<li class="js-profile">
						<a href="/profile" class="js-profile">Profile</a>
					<li class="js-brands">
						<a href="/brands" class="js-brands">Brands</a>

			{{> yield}}
		{{/if }}

Hi Clayton,
Can you check your database and make sure they are in there?
You need to make sure you publish a null subscription as well.

Meteor.publish(null, function () {
  if (this.userId) {
    return Meteor.roleAssignment.find({ 'user._id': this.userId });
  } else {
1 Like

Yep, I have that bit of code running as well. And they are in my DB, the roles and role-assignments.

The way I’ve had it work for a while is to publish the entire user object and then check if it’s in role. It is just in the data so you check the key exists, there is no helper or wrapper for it. Just literally checking if the role == ‘client’ etc hope that helps

1 Like

I’ve never used that helper. I’ve always added my own helper. Something like:

 isInRole(): {
  return Roles.userIsInRole(Meteor.userId(), ['client'])
1 Like