2014-03-11 20:23:32 +04:00
|
|
|
var AuthenticatedRoute = Ember.Route.extend({
|
2014-05-15 03:36:13 +04:00
|
|
|
beforeModel: function () {
|
2014-05-09 09:00:10 +04:00
|
|
|
var user = this.container.lookup('user:current');
|
|
|
|
|
|
|
|
if (!user || !user.get('isSignedIn')) {
|
2014-05-15 03:36:13 +04:00
|
|
|
this.notifications.showError('Please sign in');
|
|
|
|
|
|
|
|
this.transitionTo('signin');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-03-11 20:23:32 +04:00
|
|
|
actions: {
|
|
|
|
error: function (error) {
|
2014-05-09 09:00:10 +04:00
|
|
|
if (error.jqXHR && error.jqXHR.status === 401) {
|
2014-03-10 07:44:08 +04:00
|
|
|
this.transitionTo('signin');
|
2014-03-11 20:23:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default AuthenticatedRoute;
|