diff --git a/ghost/admin/app/authenticators/oauth2-ghost.js b/ghost/admin/app/authenticators/oauth2-ghost.js index 83a3eb62c2..fcb9eed2c1 100644 --- a/ghost/admin/app/authenticators/oauth2-ghost.js +++ b/ghost/admin/app/authenticators/oauth2-ghost.js @@ -32,8 +32,8 @@ export default Oauth2Authenticator.extend({ } resolve(response); }); - }, (xhr) => { - run(null, reject, xhr.responseJSON || xhr.responseText); + }, (error) => { + reject(error); }); }); } diff --git a/ghost/admin/app/routes/application.js b/ghost/admin/app/routes/application.js index 60a35eb6bb..ca66c93bc4 100644 --- a/ghost/admin/app/routes/application.js +++ b/ghost/admin/app/routes/application.js @@ -5,7 +5,7 @@ import run from 'ember-runloop'; import {isEmberArray} from 'ember-array/utils'; import observer from 'ember-metal/observer'; import $ from 'jquery'; - +import {isUnauthorizedError} from 'ember-ajax/errors'; import AuthConfiguration from 'ember-simple-auth/configuration'; import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route'; @@ -195,6 +195,11 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, { save: K, error(error, transition) { + // unauthoirized errors are already handled in the ajax service + if (isUnauthorizedError(error)) { + return false; + } + if (error && isEmberArray(error.errors)) { switch (error.errors[0].errorType) { case 'NotFoundError': {