0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/routes/authenticated.js

25 lines
742 B
JavaScript
Raw Normal View History

var AuthenticatedRoute = Ember.Route.extend({
beforeModel: function (transition) {
var user = this.container.lookup('user:current');
if (!user || !user.get('isSignedIn')) {
this.redirectToSignin(transition);
}
},
redirectToSignin: function (transition) {
this.notifications.showError('Please sign in');
if (transition) {
this.controllerFor('application').set('loginTransition', transition);
}
this.transitionTo('signin');
},
actions: {
error: function (error) {
if (error.jqXHR && error.jqXHR.status === 401) {
this.redirectToSignin();
}
}
}
});
export default AuthenticatedRoute;