如果用户登录在meteor中显示 logintemplate ,否则显示索引模板。我想当用户登录显示登录后页面时没关系。但是我想问我们什么时候在网页网址后点击登录模板,如(/ admin)它会打开我想要什么时候我们给/ admin显示主页不显示管理页面.plz建议我。
答案 0 :(得分:1)
也许你在看这个。
使用JSCode。
Router.route('/', function () {
if(Meteor.userId(){
this.render('loginTemplate');
}else{
this.render('login')
}
});
使用Spacebars 。
{{#if currentUser}}
{{> loginTemplate}}
{{else}}
{{> login}}
{{/if}}
使用onBeforeAction
首先功能
var requireLogin = function() {
if (! Meteor.user()) {
if (Meteor.loggingIn()) {
this.render(this.loadingTemplate);
} else {
this.render('accessDenied');
}
} else {
this.next();
}
}
第二次 onBeforeAction
Router.onBeforeAction(requireLogin, {only: 'loginTemplate'}); // this will only been applied to the `loginTemplate`.