Skip to content

Commit

Permalink
Display error message on setup if origin doesn't match config.js url
Browse files Browse the repository at this point in the history
refs TryGhost#6106
- add error handler for authentication step of blog setup
- move setup acceptance test out of 'settings' folder
  • Loading branch information
kevinansfield committed Nov 26, 2015
1 parent 03760c3 commit 0462dfe
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 175 deletions.
30 changes: 23 additions & 7 deletions core/client/app/controllers/setup/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ export default Ember.Controller.extend(ValidationEngine, {
});
},

_handleSaveError: function (resp) {
this.toggleProperty('submitting');
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) {
this.set('flowErrors', resp.jqXHR.responseJSON.errors[0].message);
} else {
this.get('notifications').showAPIError(resp, {key: 'setup.blog-details'});
}
},

_handleAuthenticationError: function (error) {
this.toggleProperty('submitting');
if (error && error.errors) {
this.set('flowErrors', error.errors[0].message);
} else {
// Connection errors don't return proper status message, only req.body
this.get('notifications').showAlert('There was a problem on the server.', {type: 'error', key: 'setup.authenticate.failed'});
}
},

actions: {
preValidate: function (model) {
// Only triggers validation if a value has been entered, preventing empty errors on focusOut
Expand Down Expand Up @@ -99,14 +118,11 @@ export default Ember.Controller.extend(ValidationEngine, {
self.toggleProperty('submitting');
self.transitionToRoute('setup.three');
}
}).catch(function (error) {
self._handleAuthenticationError(error);
});
}).catch(function (resp) {
self.toggleProperty('submitting');
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) {
self.set('flowErrors', resp.jqXHR.responseJSON.errors[0].message);
} else {
notifications.showAPIError(resp, {key: 'setup.blog-details'});
}
}).catch(function (error) {
self._handleSaveError(error);
});
}).catch(function () {
self.toggleProperty('submitting');
Expand Down
168 changes: 0 additions & 168 deletions core/client/tests/acceptance/settings/setup-test.js

This file was deleted.

Loading

0 comments on commit 0462dfe

Please sign in to comment.