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:
parent
d0d97d1aa2
commit
a6e3f704e5
2 changed files with 8 additions and 3 deletions
|
@ -32,8 +32,8 @@ export default Oauth2Authenticator.extend({
|
|||
}
|
||||
resolve(response);
|
||||
});
|
||||
}, (xhr) => {
|
||||
run(null, reject, xhr.responseJSON || xhr.responseText);
|
||||
}, (error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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': {
|
||||
|
|
Loading…
Add table
Reference in a new issue