根路径example.com
是否可以为未登录的用户显示登录页面(application/index
),但为登录的用户显示个人资料页面users/show
)在?
Guest user -> example.com -> application/index
Authenticated user -> example.com -> users/show
我知道这违背了Ember的应用状态被网址反映的理念,但是,是否有人知道这种情况是否可能发生?
干杯!
答案 0 :(得分:1)
是的,你可以做到。首先,您应该检查登录的用户是否在" beforeModel" "应用"路线。如果用户已登录,则将其转换为" profile"页面使用" transitionTo"否则将其转移到"登录"页。
beforeModel: function(transition) {
var user;
//put here method to check if user is logged in or not
if (!user) {
//if no user then transist to login
this.transitionTo('login');
} else {
//other wise to profile page
this.transitionTo('profilePage');
}
}