0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

🐛 fix oauth2-ghost authenticator error handling

no issue
- updates `oauth2-ghost` authenticator to reflect the fact that `makeRequest` now returns a ember-ajax and matches the `oauth2` authenticator behaviour
- handle `UnauthorizedError` errors in application route's error handler to avoid tests breaking from unhandled exceptions
This commit is contained in:
Kevin Ansfield 2017-03-10 17:36:48 +00:00 committed by Katharina Irrgang
parent d0d97d1aa2
commit a6e3f704e5
2 changed files with 8 additions and 3 deletions

View file

@ -32,8 +32,8 @@ export default Oauth2Authenticator.extend({
} }
resolve(response); resolve(response);
}); });
}, (xhr) => { }, (error) => {
run(null, reject, xhr.responseJSON || xhr.responseText); reject(error);
}); });
}); });
} }

View file

@ -5,7 +5,7 @@ import run from 'ember-runloop';
import {isEmberArray} from 'ember-array/utils'; import {isEmberArray} from 'ember-array/utils';
import observer from 'ember-metal/observer'; import observer from 'ember-metal/observer';
import $ from 'jquery'; import $ from 'jquery';
import {isUnauthorizedError} from 'ember-ajax/errors';
import AuthConfiguration from 'ember-simple-auth/configuration'; import AuthConfiguration from 'ember-simple-auth/configuration';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route'; import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
@ -195,6 +195,11 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
save: K, save: K,
error(error, transition) { error(error, transition) {
// unauthoirized errors are already handled in the ajax service
if (isUnauthorizedError(error)) {
return false;
}
if (error && isEmberArray(error.errors)) { if (error && isEmberArray(error.errors)) {
switch (error.errors[0].errorType) { switch (error.errors[0].errorType) {
case 'NotFoundError': { case 'NotFoundError': {