2015-08-31 16:59:56 +03:00
|
|
|
import Ember from 'ember';
|
2015-10-18 21:17:02 +03:00
|
|
|
import Authenticator from 'ember-simple-auth/authenticators/oauth2-password-grant';
|
2015-08-28 18:00:34 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {computed, inject} = Ember;
|
|
|
|
|
2015-08-28 18:00:34 +03:00
|
|
|
export default Authenticator.extend({
|
2015-10-28 14:36:45 +03:00
|
|
|
config: inject.service(),
|
|
|
|
ghostPaths: inject.service('ghost-paths'),
|
2015-10-18 21:17:02 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
serverTokenEndpoint: computed('ghostPaths.apiRoot', function () {
|
|
|
|
return `${this.get('ghostPaths.apiRoot')}/authentication/token`;
|
2015-10-18 21:17:02 +03:00
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
serverTokenRevocationEndpoint: computed('ghostPaths.apiRoot', function () {
|
|
|
|
return `${this.get('ghostPaths.apiRoot')}/authentication/revoke`;
|
2015-10-18 21:17:02 +03:00
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
makeRequest(url, data) {
|
|
|
|
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
2015-08-31 16:59:56 +03:00
|
|
|
data.client_id = this.get('config.clientId');
|
|
|
|
data.client_secret = this.get('config.clientSecret');
|
2015-10-28 14:36:45 +03:00
|
|
|
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
2015-08-28 18:00:34 +03:00
|
|
|
return this._super(url, data);
|
|
|
|
}
|
|
|
|
});
|