mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
d53ef125e0
no issue - updates `package.json` details to better reflect the separation from the `Ghost` package - update ember config and all import statements to reflect the new `ghost-admin` module name in `package.json`
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import Ember from 'ember';
|
|
import Configuration from 'ember-simple-auth/configuration';
|
|
import styleBody from 'ghost-admin/mixins/style-body';
|
|
|
|
const {
|
|
Route,
|
|
inject: {service}
|
|
} = Ember;
|
|
|
|
export default Route.extend(styleBody, {
|
|
titleToken: 'Setup',
|
|
|
|
classNames: ['ghost-setup'],
|
|
|
|
ghostPaths: service('ghost-paths'),
|
|
session: service(),
|
|
ajax: service(),
|
|
|
|
// 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() {
|
|
this._super(...arguments);
|
|
|
|
if (this.get('session.isAuthenticated')) {
|
|
this.transitionTo(Configuration.routeIfAlreadyAuthenticated);
|
|
return;
|
|
}
|
|
|
|
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
|
|
|
// If user is not logged in, check the state of the setup process via the API
|
|
return this.get('ajax').request(authUrl)
|
|
.then((result) => {
|
|
let [setup] = result.setup;
|
|
|
|
if (setup.status) {
|
|
return this.transitionTo('signin');
|
|
} else {
|
|
let controller = this.controllerFor('setup/two');
|
|
if (setup.title) {
|
|
controller.set('blogTitle', setup.title.replace(/'/gim, '\''));
|
|
}
|
|
|
|
if (setup.name) {
|
|
controller.set('name', setup.name.replace(/'/gim, '\''));
|
|
}
|
|
|
|
if (setup.email) {
|
|
controller.set('email', setup.email);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
deactivate() {
|
|
this._super(...arguments);
|
|
this.controllerFor('setup/two').set('password', '');
|
|
}
|
|
});
|