-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [x] Strip jQuery in ember-cli-build.js * [x] Try to ember-data to use ember-fetch instead of $.ajax * [x] app/adapters/application.js added the authorization: <bearer token> header to outgoing requests * [x] ma-create-media guards against disabled button * [x] updated dependencies
- Loading branch information
Showing
6 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
import DS from 'ember-data'; | ||
import { get } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch'; | ||
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; | ||
import JSONAPIAdapter from 'ember-data/adapters/json-api'; | ||
import config from 'mir/config/environment'; | ||
|
||
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { | ||
const TOKEN_KEY = 'session.session.authenticated.access_token'; | ||
|
||
export default JSONAPIAdapter.extend(AdapterFetch, DataAdapterMixin, { | ||
session: service(), | ||
|
||
/* Ember */ | ||
host: config.DS.host, | ||
namespace: config.DS.namespace, | ||
|
||
/* ember-simple-auth */ | ||
authorizer: 'authorizer:oauth2' | ||
authorizer: 'authorizer:oauth2', | ||
|
||
/* mir */ | ||
ajaxOptions() { | ||
this._super(...arguments); | ||
const options = this._super(...arguments) || {}; | ||
const token = get(this, TOKEN_KEY); | ||
options.headers = options.headers || {}; | ||
options.headers['Content-Type'] = 'application/vnd.api+json'; | ||
options.headers['Authorization'] = `Bearer ${token}`; | ||
return options; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters