2014-08-10 18:48:11 +04:00
|
|
|
import ghostPaths from 'ghost/utils/ghost-paths';
|
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
var Ghost,
|
|
|
|
AuthenticationInitializer;
|
2014-08-10 18:48:11 +04:00
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
Ghost = ghostPaths();
|
2014-06-30 16:58:10 +04:00
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
AuthenticationInitializer = {
|
2014-06-30 16:58:10 +04:00
|
|
|
name: 'authentication',
|
2014-07-25 17:38:13 +04:00
|
|
|
before: 'simple-auth',
|
2014-06-30 16:58:10 +04:00
|
|
|
after: 'registerTrailingLocationHistory',
|
|
|
|
|
2014-07-25 17:38:13 +04:00
|
|
|
initialize: function (container) {
|
|
|
|
window.ENV = window.ENV || {};
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-07-25 17:38:13 +04:00
|
|
|
window.ENV['simple-auth'] = {
|
|
|
|
authenticationRoute: 'signin',
|
2014-12-08 03:31:24 +03:00
|
|
|
routeAfterAuthentication: 'posts',
|
2014-11-22 20:43:32 +03:00
|
|
|
authorizer: 'simple-auth-authorizer:oauth2-bearer',
|
|
|
|
localStorageKey: 'ghost' + (Ghost.subdir.indexOf('/') === 0 ? '-' + Ghost.subdir.substr(1) : '') + ':session'
|
|
|
|
};
|
|
|
|
|
|
|
|
window.ENV['simple-auth-oauth2'] = {
|
|
|
|
serverTokenEndpoint: Ghost.apiRoot + '/authentication/token',
|
|
|
|
serverTokenRevocationEndpoint: Ghost.apiRoot + '/authentication/revoke',
|
|
|
|
refreshAccessTokens: true
|
2014-07-25 17:38:13 +04:00
|
|
|
};
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-07-25 17:38:13 +04:00
|
|
|
SimpleAuth.Session.reopen({
|
2014-12-08 03:31:24 +03:00
|
|
|
user: Ember.computed(function () {
|
2014-07-01 19:58:26 +04:00
|
|
|
return container.lookup('store:main').find('user', 'me');
|
2014-12-08 03:31:24 +03:00
|
|
|
})
|
2014-07-01 19:58:26 +04:00
|
|
|
});
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-07-25 17:38:13 +04:00
|
|
|
SimpleAuth.Authenticators.OAuth2.reopen({
|
|
|
|
makeRequest: function (url, data) {
|
2014-06-30 16:58:10 +04:00
|
|
|
data.client_id = 'ghost-admin';
|
2014-07-25 17:38:13 +04:00
|
|
|
return this._super(url, data);
|
2014-06-30 16:58:10 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-01 19:58:26 +04:00
|
|
|
export default AuthenticationInitializer;
|