mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
3ae3e8142a
Refs https://www.notion.so/ghost/Invite-staff-users-steps-in-setup-guide-367737e13d97450a98a0f39ec6b68181 * Simplified the selfhoster setup flow to one setup page only * Redesigned the reset password pages and the signup page for new staff members Co-authored-by: Daniel Lockyer <hi@daniellockyer.com>
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class SetupRoute extends Route {
|
|
@service ghostPaths;
|
|
@service session;
|
|
@service ajax;
|
|
@service config;
|
|
|
|
// 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() {
|
|
super.beforeModel(...arguments);
|
|
|
|
if (this.session.isAuthenticated) {
|
|
return this.transitionTo('home');
|
|
}
|
|
|
|
let authUrl = this.ghostPaths.url.api('authentication', 'setup');
|
|
|
|
// check the state of the setup process via the API
|
|
return this.ajax.request(authUrl)
|
|
.then((result) => {
|
|
let [setup] = result.setup;
|
|
|
|
if (setup.status) {
|
|
return this.transitionTo('signin');
|
|
} else {
|
|
let controller = this.controllerFor('setup');
|
|
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() {
|
|
super.deactivate(...arguments);
|
|
this.controllerFor('setup').set('password', '');
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Setup',
|
|
bodyClasses: ['unauthenticated-route'],
|
|
mainClasses: ['gh-main-white']
|
|
};
|
|
}
|
|
}
|