1
我已經創造了本教程現在一個簡單的身份驗證:打開面板/模態的路線 - Ember.JS
http://www.embercasts.com/episodes/client-side-authentication-part-1
所以我創建了AuthenticatedRoute,和所有其他的路線,需要一個記錄在用戶中,正在擴展AuthenticatedRoute。
而在beforeModel中,我檢查用戶是否登錄。如果他沒有登錄,我打電話:this.transitionTo("login")
。
我現在的問題是:我怎麼能把整個登錄表單放在面板中? 我的想法是打開AuthenticatedRoute - > beforeModel事件中的面板,如果登錄成功,請重試重定向。
我的想法,但我不知道如何實現它。
App.AuthenticatedRoute = Ember.Route.extend({
beforeModel: function(transition) {
if (!App.get("currentUser")) {
transition.abort(); // loading spinner doesn't disappears if i call this??
this.showLogin(transition);
}
},
showLogin: function(transition) {
var loginController = this.controllerFor("login");
loginController.set("attemptedTransition", transition);
// OPEN PANEL, if the panel gets closed, do nothing. If login successfull, redirect to attemptedTransition and hide the panel.
}
});