This code works good
{
action: function() {
this.render('userprofile');
},
onBeforeAction: function() {
this.redirect('/mypage');
}
});
But no such
{
action: function() {
this.render('userprofile');
},
onBeforeAction: function() {
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage');
this.stop();
} else {
this.next()
}
}
});
And
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage')
} else {
this.next()
}
If you enter incorrect uname
this condition work
} else {
this.next()
}
And if it is true
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage');
this.stop();
}
Page only changes the link from /StevePi (correct uname) to /mypage but not render
I tried to use Router.go()
and other methods , but it did not help :(
I realized this is the case (maybe it will help someone):
Router.route('/:uname', function() {
if (Meteor.user().profile.uname == this.params.uname) {
window.location.href = "/mypage"; <---------------------------------
} else {
this.render('userprofile')
}
});