diff --git a/core/client/app/controllers/setup.js b/core/client/app/controllers/setup.js index 84e4e891ec..ebd05ef2ff 100644 --- a/core/client/app/controllers/setup.js +++ b/core/client/app/controllers/setup.js @@ -1,54 +1,15 @@ import Ember from 'ember'; -import {request as ajax} from 'ic-ajax'; -import ValidationEngine from 'ghost/mixins/validation-engine'; - -export default Ember.Controller.extend(ValidationEngine, { - blogTitle: null, - name: null, - email: null, - password: null, - submitting: false, - - // ValidationEngine settings - validationType: 'setup', +export default Ember.Controller.extend({ + appController: Ember.inject.controller('application'), ghostPaths: Ember.inject.service('ghost-paths'), - notifications: Ember.inject.service(), - actions: { - setup: function () { - var self = this, - data = self.getProperties('blogTitle', 'name', 'email', 'password'), - notifications = this.get('notifications'); + showBackLink: Ember.computed.match('appController.currentRouteName', /^setup\.(two|three)$/), - notifications.closePassive(); + backRoute: Ember.computed('appController.currentRouteName', function () { + var appController = this.get('appController'), + currentRoute = Ember.get(appController, 'currentRouteName'); - this.toggleProperty('submitting'); - this.validate({format: false}).then(function () { - ajax({ - url: self.get('ghostPaths.url').api('authentication', 'setup'), - type: 'POST', - data: { - setup: [{ - name: data.name, - email: data.email, - password: data.password, - blogTitle: data.blogTitle - }] - } - }).then(function () { - self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { - identification: self.get('email'), - password: self.get('password') - }); - }).catch(function (resp) { - self.toggleProperty('submitting'); - notifications.showAPIError(resp); - }); - }).catch(function (errors) { - self.toggleProperty('submitting'); - notifications.showErrors(errors); - }); - } - } + return currentRoute === 'setup.two' ? 'setup.one' : 'setup.two'; + }) }); diff --git a/core/client/app/controllers/setup/three.js b/core/client/app/controllers/setup/three.js index e05006227e..29dd0df2a2 100644 --- a/core/client/app/controllers/setup/three.js +++ b/core/client/app/controllers/setup/three.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -var SetupThreeController = Ember.Controller.extend({ +export default Ember.Controller.extend({ notifications: Ember.inject.service(), users: '', usersArray: Ember.computed('users', function () { @@ -133,4 +133,3 @@ var SetupThreeController = Ember.Controller.extend({ } }); -export default SetupThreeController; diff --git a/core/client/app/controllers/setup/two.js b/core/client/app/controllers/setup/two.js index 251d873470..400e4c0efb 100644 --- a/core/client/app/controllers/setup/two.js +++ b/core/client/app/controllers/setup/two.js @@ -9,7 +9,6 @@ export default Ember.Controller.extend(ValidationEngine, { email: '', password: null, image: null, - submitting: false, blogCreated: false, ghostPaths: Ember.inject.service('ghost-paths'), @@ -52,9 +51,8 @@ export default Ember.Controller.extend(ValidationEngine, { data = self.getProperties('blogTitle', 'name', 'email', 'password', 'image'), notifications = this.get('notifications'), config = this.get('config'), - method = (this.get('blogCreated')) ? 'PUT' : 'POST'; + method = this.get('blogCreated') ? 'PUT' : 'POST'; - this.toggleProperty('submitting'); this.validate().then(function () { self.set('showError', false); ajax({ @@ -72,14 +70,12 @@ export default Ember.Controller.extend(ValidationEngine, { config.set('blogTitle', data.blogTitle); // Don't call the success handler, otherwise we will be redirected to admin self.get('application').set('skipAuthSuccessHandler', true); - self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { identification: self.get('email'), password: self.get('password') }).then(function () { self.set('password', ''); self.set('blogCreated', true); - if (data.image) { self.sendImage(result.users[0]) .then(function () { @@ -92,11 +88,9 @@ export default Ember.Controller.extend(ValidationEngine, { } }); }).catch(function (resp) { - self.toggleProperty('submitting'); notifications.showAPIError(resp); }); }).catch(function () { - self.toggleProperty('submitting'); self.set('showError', true); }); }, diff --git a/core/client/app/routes/setup/three.js b/core/client/app/routes/setup/three.js new file mode 100644 index 0000000000..aa59dc20c3 --- /dev/null +++ b/core/client/app/routes/setup/three.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + beforeModel: function () { + if (!this.controllerFor('setup.two').get('blogCreated')) { + this.transitionTo('setup.two'); + } + } +}); diff --git a/core/client/app/templates/setup.hbs b/core/client/app/templates/setup.hbs index f86f04cb95..a0153448ee 100644 --- a/core/client/app/templates/setup.hbs +++ b/core/client/app/templates/setup.hbs @@ -1,8 +1,9 @@
So far there have been {{model.count}} Ghost blogs made by people all over the world. Today we’re making yours.
-So far there have been {{model.count}} Ghost blogs made by people all over the world. Today we’re making yours.
+Ghost works best when shared with others. Collaborate, get feedback on your posts & work together on ideas.
-Ghost works best when shared with others. Collaborate, get feedback on your posts & work together on ideas.
+{{invalidMessage}}
- {{/if}} -{{#if showError}}{{invalidMessage}}{{/if}}