2014-06-25 16:12:48 +04:00
|
|
|
import styleBody from 'ghost/mixins/style-body';
|
|
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
|
|
|
|
|
|
var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
2014-11-25 23:56:08 +03:00
|
|
|
titleToken: 'Setup',
|
|
|
|
|
2014-07-01 14:57:44 +04:00
|
|
|
classNames: ['ghost-setup'],
|
2014-07-15 23:52:44 +04:00
|
|
|
|
|
|
|
// use the beforeModel hook to check to see whether or not setup has been
|
|
|
|
// previously completed. If it has, stop the transition into the setup page.
|
|
|
|
|
2014-07-01 14:57:44 +04:00
|
|
|
beforeModel: function () {
|
2014-07-15 23:52:44 +04:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
// If user is logged in, setup has already been completed.
|
2014-07-01 14:57:44 +04:00
|
|
|
if (this.get('session').isAuthenticated) {
|
2014-07-25 17:38:13 +04:00
|
|
|
this.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
|
2014-07-15 23:52:44 +04:00
|
|
|
return;
|
2014-07-01 14:57:44 +04:00
|
|
|
}
|
2014-07-15 23:52:44 +04:00
|
|
|
|
|
|
|
// If user is not logged in, check the state of the setup process via the API
|
|
|
|
return ic.ajax.request(this.get('ghostPaths.url').api('authentication/setup'), {
|
|
|
|
type: 'GET'
|
|
|
|
}).then(function (result) {
|
|
|
|
var setup = result.setup[0].status;
|
|
|
|
|
|
|
|
if (setup) {
|
|
|
|
return self.transitionTo('signin');
|
|
|
|
}
|
|
|
|
});
|
2014-07-01 14:57:44 +04:00
|
|
|
}
|
2014-06-25 16:12:48 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default SetupRoute;
|