1541b92ccf
Closes #2092 - Adds styling for re-auth modal. - Prevent transition to posts route on success. - Clear credentials from controller. - Handle confirmAccept action if form is submitted via 'enter'. - Only allow re-auth as the user that was previously logged in.
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: 'posts',
|
|
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
|
|
};
|
|
|
|
SimpleAuth.Session.reopen({
|
|
user: Ember.computed(function () {
|
|
return container.lookup('store:main').find('user', 'me');
|
|
})
|
|
});
|
|
|
|
SimpleAuth.Authenticators.OAuth2.reopen({
|
|
makeRequest: function (url, data) {
|
|
data.client_id = 'ghost-admin';
|
|
return this._super(url, data);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
export default AuthenticationInitializer;
|