Im trying to have "user permissions" eg Admin, User. Im trying to make the side nav only display the link if the user is Admin
if (Meteor.isClient) {
Template.side_nav.helpers({
isAdmin: function(group) {
console.log(group);
return this.group === "Admin";
}
});
}
{{#if isAdmin {{currentUser.profile.group}}}
<ul class="nav nav-sidebar">
<li><a href="{{pathFor route='register'}}">Add User</a></li>
<li><a href="{{pathFor route='panel-remove'}}">Remove User</a></li>
<li><a href="{{pathFor route='panel-dashboard'}}k">Block IP</a></li>
<li><a href="{{pathFor route='panel-dashboard'}}">Edit Rules</a></li>
<li><a href="{{pathFor route='panel-dashboard'}}">Settings</a></li>
</ul>
{{/if}}
The template for the side navigation is called "side_nav". Not sure why it isnt working, When I put in the variable it just errors, when i put it in quotations mark it just outputs the actual string ({{currentUser..}}), When I hard code "Admin" into the if statement it still doesn't work...
If you want to pass the value currentUser.profile.group to the isAdmin helper (not insert its value into the template), you'll need to drop the curly braces:
{{#if isAdmin currentUser.profile.group}}
I'm not sure what exactly the isAdmin helper is supposed to do, but if you want to check if the group passed in is 'Admin', then you should drop the this:
return group === "Admin";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With