確保用戶登錄到Ember應用程序的最佳方式是什麼?確保用戶在Ember應用程序中登錄
我想在路由激動之前攔截任何URL,顯示帶有user_id /密碼的模式彈出窗口,並轉到原始URL。
也許類似於Rail的application_controller#before_filter,它在任何其他控制器方法之前執行。
我有以下路徑:
App.Router.map(function(){
this.resource('folder', {path: '/'}, function(){
this.resource('files', {path: '/:folder_id'}, function(){
this.route('index');
});
});
});
我試圖建立ApplicationRoute:
App.ApplicationRoute = Ember.Route.extend({
activate: function(){
console.log("activating app route");
}
});
但問題是,如果我打index.html#/folder01
,folder
路線是application
路線之前執行。
總結工作流程的理想應該是這樣:
- 用戶點擊
index.html#/folder01
URL - 應用程序檢查用戶是否登錄如果沒有模式彈出出現
- 登錄後,應用程序應該呈現
index.html#/folder01
URL
非常感謝!
請看[this](http://stackoverflow.com/questions/15416143/ember-js-authentication/15429584#15429584)especialy the redirect method – pjlammertyn 2013-03-21 19:19:44