mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
20 lines
592 B
JavaScript
20 lines
592 B
JavaScript
import $ from 'jquery';
|
|
import {assign} from 'ember-platform';
|
|
|
|
export default {
|
|
name: 'jquery-ajax-oauth-prefilter',
|
|
after: 'ember-simple-auth',
|
|
|
|
initialize(application) {
|
|
let session = application.lookup('service:session');
|
|
|
|
$.ajaxPrefilter(function (options) {
|
|
session.authorize('authorizer:oauth2', function (headerName, headerValue) {
|
|
let headerObject = {};
|
|
|
|
headerObject[headerName] = headerValue;
|
|
options.headers = assign(options.headers || {}, headerObject);
|
|
});
|
|
});
|
|
}
|
|
};
|