I have the folowing problem with Meteor: I have one admin, that needs to see all registered users. But all the other users shouldn't have the ability to see the other users. Therefore I published the following code on the serverside
Meteor.publish("adminUsers", function(){
var result;
if (Roles.userIsInRole(this.userId, ["admin"]))
{
result = Meteor.users.find();
}
//console.log(result);
return result;
});
On client side I subscribe to this with
Meteor.subscribe("adminUsers");
And do
AllUsers = new Meteor.Collection("adminUsers");
Now I want to get all the Users in a Template with this code:
Template.adminUserverwaltung.AllUsers = function(){
console.log(AllUsers.find());
return AllUsers.find();
}
and show the result in the template with this code:
<template name="adminUserverwaltung">
{{#each AllUsers}}
{{this.username}}
{{/each}}
</template>
But unfortunately it is not working... Can anyone help me maybe?