Ghost/core/client/initializers/authentication.js
Kevin Ansfield 7bfe6e9db7 Fix direct access to settings/user
closes #3162
- removes injection of user object in application route's beforeModel
- removes injection/cleanup of user object in signedIn/signedOut actions
- removes loading of user and passing to signedIn action in signup/setup controllers
- adds 'user' property to session object
- updates header nav to reference session.user
- sets model of settings/user route to session.user and forces reload
- on leaving settings/user, rollback any unsaved changes
2014-07-02 17:45:21 +02:00

29 lines
963 B
JavaScript

var AuthenticationInitializer = {
name: 'authentication',
after: 'registerTrailingLocationHistory',
initialize: function (container, application) {
Ember.SimpleAuth.Session.reopen({
user: function () {
return container.lookup('store:main').find('user', 'me');
}.property()
});
Ember.SimpleAuth.Authenticators.OAuth2.reopen({
serverTokenEndpoint: '/ghost/api/v0.1/authentication/token',
refreshAccessTokens: true,
makeRequest: function (data) {
data.client_id = 'ghost-admin';
return this._super(data);
}
});
Ember.SimpleAuth.setup(container, application, {
authenticationRoute: 'signin',
routeAfterAuthentication: 'content',
authorizerFactory: 'ember-simple-auth-authorizer:oauth2-bearer'
});
}
};
export default AuthenticationInitializer;