fix user not defined issue in user menu

This commit is contained in:
Sacha Greif 2015-07-27 15:10:48 +09:00
parent 94b3b874d4
commit 975439cdd9
2 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,7 @@
getRoute = function (item) {
// if route is a Function return its result, else apply Router.path() to it
return typeof item.route == "function" ? item.route() : Router.path(item.route);
}
return typeof item.route === "function" ? item.route() : Router.path(item.route);
};
// filter out admin-only items if needed
getMenuItems = function (menu) {
@ -14,7 +14,7 @@ getMenuItems = function (menu) {
}
return menuItems;
}
};
Template.menuComponent.helpers({
getMenuItems: function () {

View file

@ -1,14 +1,16 @@
Telescope.menuItems.add("userMenu", [
{
route: function () {
return Router.path('user_profile', {_idOrSlug: Meteor.user().telescope.slug});
var user = Meteor.user();
return Router.path('user_profile', {_idOrSlug: user && user.telescope.slug});
},
label: 'profile',
description: 'view_your_profile'
},
{
route: function () {
return Router.path('user_edit', {slug: Meteor.user().telescope.slug});
var user = Meteor.user();
return Router.path('user_edit', {slug: user && user.telescope.slug});
},
label: 'edit_account',
description: 'edit_your_profile'