I have a Meteor helper that checks to see if the user has the correct permissions.
cad.js
Template.cad.helpers({
pageAccess() {
const user = Meteor.users.findOne({_id: this.userId});
const user_department = Meteor.users.findOne({_id: this.userId}).profile.department;
const communications_departments = Settings.findOne({_id: 'settings'}).communications_departments;
if (user && communications_departments.includes(user_department)) {
Meteor.subscribe('calls');
Meteor.subscribe('users');
Meteor.subscribe('settings');
return true;
} else {
return false;
}
},
)};
cad.html
<template name="cad">
{{#if pageAccess}}
{{> cad}}
{{else}}
No access.
{{/if}
</template>
For some reason, even though the user has the correct group, the page will not show up correctly.
Similarly, my router won’t correctly return either. The user is in the correct group but it won’t seem to render.
routes.js
Router.route('/communications', function () {
const user = Meteor.users.findOne({_id: this.userId});
const user_department = Meteor.users.findOne({_id: this.userId}).profile.department;
const communications_departments = Settings.findOne({_id: 'settings'}).communications_departments;
if (user && communications_departments.includes(user_department)) {
this.render('communications');
}
}, {
name: 'communications'
});