diff --git a/core/client/app/controllers/setup/two.js b/core/client/app/controllers/setup/two.js index c506e723e1..4daa93da04 100644 --- a/core/client/app/controllers/setup/two.js +++ b/core/client/app/controllers/setup/two.js @@ -12,6 +12,7 @@ export default Ember.Controller.extend(ValidationEngine, { image: null, blogCreated: false, submitting: false, + flowErrors: '', ghostPaths: Ember.inject.service('ghost-paths'), notifications: Ember.inject.service(), @@ -56,9 +57,9 @@ export default Ember.Controller.extend(ValidationEngine, { method = this.get('blogCreated') ? 'PUT' : 'POST'; this.toggleProperty('submitting'); + this.set('flowErrors', ''); this.validate().then(function () { - self.set('showError', false); ajax({ url: self.get('ghostPaths.url').api('authentication', 'setup'), type: method, @@ -96,11 +97,15 @@ export default Ember.Controller.extend(ValidationEngine, { }); }).catch(function (resp) { self.toggleProperty('submitting'); - notifications.showAPIError(resp); + if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) { + self.set('flowErrors', resp.jqXHR.responseJSON.errors[0].message); + } else { + notifications.showAPIError(resp); + } }); }).catch(function () { self.toggleProperty('submitting'); - self.set('showError', true); + self.set('flowErrors', 'Please fill out the form to setup your blog.'); }); }, setImage: function (image) { diff --git a/core/client/app/controllers/signup.js b/core/client/app/controllers/signup.js index 0f360786a2..f9f81d5964 100644 --- a/core/client/app/controllers/signup.js +++ b/core/client/app/controllers/signup.js @@ -7,6 +7,7 @@ export default Ember.Controller.extend(ValidationEngine, { validationType: 'signup', submitting: false, + flowErrors: '', ghostPaths: Ember.inject.service('ghost-paths'), notifications: Ember.inject.service(), @@ -18,6 +19,7 @@ export default Ember.Controller.extend(ValidationEngine, { data = model.getProperties('name', 'email', 'password', 'token'), notifications = this.get('notifications'); + this.set('flowErrors', ''); notifications.closeNotifications(); this.validate().then(function () { @@ -41,12 +43,14 @@ export default Ember.Controller.extend(ValidationEngine, { }); }).catch(function (resp) { self.toggleProperty('submitting'); - notifications.showAPIError(resp); + if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) { + self.set('flowErrors', 'That email address is already in use.'); + } else { + notifications.showAPIError(resp); + } }); - }).catch(function (error) { - if (error) { - notifications.showAPIError(error); - } + }).catch(function () { + self.set('flowErrors', 'Please fill out the form to complete your sign-up'); }); } } diff --git a/core/client/app/templates/setup/two.hbs b/core/client/app/templates/setup/two.hbs index ba333643af..2c9d1bb2e3 100644 --- a/core/client/app/templates/setup/two.hbs +++ b/core/client/app/templates/setup/two.hbs @@ -40,4 +40,5 @@ {{#gh-spin-button type="button" class="btn btn-green btn-lg btn-block" action="setup" submitting=submitting autoWidth=false}} Last step: Invite your team {{/gh-spin-button}} -
{{#if showError}}{{invalidMessage}}{{/if}}
+ +{{{flowErrors}}}
diff --git a/core/client/app/templates/signup.hbs b/core/client/app/templates/signup.hbs index 346ddaa7c0..b6a5e35eb6 100644 --- a/core/client/app/templates/signup.hbs +++ b/core/client/app/templates/signup.hbs @@ -21,21 +21,21 @@ {{#gh-form-group errors=model.errors property="email"}} {{gh-error-message errors=model.errors property="email"}} {{/gh-form-group}} {{#gh-form-group errors=model.errors property="name"}} {{gh-error-message errors=model.errors property="name"}} {{/gh-form-group}} {{#gh-form-group errors=model.errors property="password"}}