mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
9adbcd1fd0
no issue Automated tools, code generators, and editor integrations are increasingly standardising on the import style used in `ember-modules-codemod`. Our import style differed a little with regards to service/controller injection imports which meant we were starting to see inconsistent naming.
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import styleBody from 'ghost-admin/mixins/style-body';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default Route.extend(styleBody, {
|
|
titleToken: 'Setup',
|
|
|
|
classNames: ['ghost-setup'],
|
|
|
|
ghostPaths: service(),
|
|
session: service(),
|
|
ajax: service(),
|
|
config: 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')) {
|
|
return this.transitionTo('posts');
|
|
}
|
|
|
|
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
|
|
|
// 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', '');
|
|
}
|
|
});
|