确保用户登录到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