mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
0f17378b26
Refs #4001 - grunt-jscs@0.8.1 which provides ES6 support.
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import ghostPaths from 'ghost/utils/ghost-paths';
|
|
|
|
var Ghost,
|
|
AuthenticationInitializer;
|
|
|
|
Ghost = ghostPaths();
|
|
|
|
AuthenticationInitializer = {
|
|
name: 'authentication',
|
|
before: 'simple-auth',
|
|
after: 'registerTrailingLocationHistory',
|
|
|
|
initialize: function (container) {
|
|
window.ENV = window.ENV || {};
|
|
|
|
window.ENV['simple-auth'] = {
|
|
authenticationRoute: 'signin',
|
|
routeAfterAuthentication: 'content',
|
|
authorizer: 'simple-auth-authorizer:oauth2-bearer'
|
|
};
|
|
|
|
SimpleAuth.Session.reopen({
|
|
user: Ember.computed(function () {
|
|
return container.lookup('store:main').find('user', 'me');
|
|
})
|
|
});
|
|
|
|
SimpleAuth.Authenticators.OAuth2.reopen({
|
|
serverTokenEndpoint: Ghost.apiRoot + '/authentication/token',
|
|
serverTokenRevocationEndpoint: Ghost.apiRoot + '/authentication/revoke',
|
|
refreshAccessTokens: true,
|
|
makeRequest: function (url, data) {
|
|
data.client_id = 'ghost-admin';
|
|
return this._super(url, data);
|
|
}
|
|
});
|
|
|
|
SimpleAuth.Stores.LocalStorage.reopen({
|
|
key: 'ghost' + (Ghost.subdir.indexOf('/') === 0 ? '-' + Ghost.subdir.substr(1) : '') + ':session'
|
|
});
|
|
}
|
|
};
|
|
|
|
export default AuthenticationInitializer;
|