javascript - Meteor : redirect if user didn't create page -
in meteor have product edit page. want user created product see page. otherwise redirected.
is there way redirect iron router only? if not i'll take solution.
router.js
var onbeforeactions; onbeforeactions = { ownerrequired: function(pause){ if(!meteor.userid()){ router.go('home'); }else if(meteor.userid()._id != ....something?....){ router.go('home'); }else{ this.next(); } } }; router.onbeforeaction(onbeforeactions.ownerrequired, { only: ['editproduct'] }); router.route('/editproduct/:_id',{ template: "editproduct", name: "editproduct", data: function(){ return products.findone({_id: this.params._id}); } });
so if want know how solve without iron router. this. (note check onbeforeaction if user logged in.)
template.editproduct.oncreated(function(){ if(this.data.user === meteor.userid()){ }else{ router.go('home'); } });
Comments
Post a Comment