Ghost/ghost/admin/app/routes/setup.js
Hannah Wolfe 6cb45d6939 Don't clear password field until setup is complete
ref #5652

- resolves issues with setup flow for the time being
- password is cleared on deactivate, rather than during step 2
- using transitionToRoute instead of transitionTo to remove deprecation warning
2015-08-25 13:16:39 +01:00

40 lines
1.2 KiB
JavaScript

import Ember from 'ember';
import {request as ajax} from 'ic-ajax';
import Configuration from 'simple-auth/configuration';
import styleBody from 'ghost/mixins/style-body';
export default Ember.Route.extend(styleBody, {
titleToken: 'Setup',
classNames: ['ghost-setup'],
ghostPaths: Ember.inject.service('ghost-paths'),
// 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.
beforeModel: function () {
var self = this;
// If user is logged in, setup has already been completed.
if (this.get('session').isAuthenticated) {
this.transitionTo(Configuration.routeAfterAuthentication);
return;
}
// If user is not logged in, check the state of the setup process via the API
return ajax(this.get('ghostPaths.url').api('authentication/setup'), {
type: 'GET'
}).then(function (result) {
var setup = result.setup[0].status;
if (setup) {
return self.transitionTo('signin');
}
});
},
deactivate: function () {
this._super();
this.controllerFor('setup/two').set('password', '');
}
});