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