mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Fix auth token refresh failing on app-boot with expired access_token
issue #5751 - moves `makeRequest` override of simple-auth's OAuth authenticator into our own custom authenticator (previously our override was not taking effect until after ember-simple-auth's initial authentication routines, hence why it was working for post-login token refreshes but failing on app-boot)
This commit is contained in:
parent
dd8da3bad7
commit
6989843b19
8
ghost/admin/app/authenticators/oauth2.js
Normal file
8
ghost/admin/app/authenticators/oauth2.js
Normal file
@ -0,0 +1,8 @@
|
||||
import Authenticator from 'simple-auth-oauth2/authenticators/oauth2';
|
||||
|
||||
export default Authenticator.extend({
|
||||
makeRequest: function (url, data) {
|
||||
data.client_id = 'ghost-admin';
|
||||
return this._super(url, data);
|
||||
}
|
||||
});
|
@ -15,7 +15,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
actions: {
|
||||
authenticate: function () {
|
||||
var appController = this.get('application'),
|
||||
authStrategy = 'simple-auth-authenticator:oauth2-password-grant',
|
||||
authStrategy = 'ghost-authenticator:oauth2-password-grant',
|
||||
data = this.getProperties('identification', 'password'),
|
||||
self = this;
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
}).then(function (resp) {
|
||||
self.toggleProperty('submitting');
|
||||
self.get('notifications').showAlert(resp.passwordreset[0].message, {type: 'warn', delayed: true});
|
||||
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
|
||||
self.get('session').authenticate('ghost-authenticator:oauth2-password-grant', {
|
||||
identification: self.get('email'),
|
||||
password: credentials.newPassword
|
||||
});
|
||||
|
@ -75,7 +75,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
config.set('blogTitle', data.blogTitle);
|
||||
// Don't call the success handler, otherwise we will be redirected to admin
|
||||
self.get('application').set('skipAuthSuccessHandler', true);
|
||||
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
|
||||
self.get('session').authenticate('ghost-authenticator:oauth2-password-grant', {
|
||||
identification: self.get('email'),
|
||||
password: self.get('password')
|
||||
}).then(function () {
|
||||
|
@ -17,7 +17,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
authenticate: function () {
|
||||
var self = this,
|
||||
model = this.get('model'),
|
||||
authStrategy = 'simple-auth-authenticator:oauth2-password-grant',
|
||||
authStrategy = 'ghost-authenticator:oauth2-password-grant',
|
||||
data = model.getProperties('identification', 'password');
|
||||
|
||||
this.get('session').authenticate(authStrategy, data).then(function () {
|
||||
|
@ -64,7 +64,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
}]
|
||||
}
|
||||
}).then(function () {
|
||||
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
|
||||
self.get('session').authenticate('ghost-authenticator:oauth2-password-grant', {
|
||||
identification: self.get('model.email'),
|
||||
password: self.get('model.password')
|
||||
}).then(function () {
|
||||
|
12
ghost/admin/app/initializers/ghost-authenticator.js
Normal file
12
ghost/admin/app/initializers/ghost-authenticator.js
Normal file
@ -0,0 +1,12 @@
|
||||
import GhostOauth2Authenticator from 'ghost/authenticators/oauth2';
|
||||
|
||||
export default {
|
||||
name: 'ghost-authentictor',
|
||||
|
||||
initialize: function (container) {
|
||||
container.register(
|
||||
'ghost-authenticator:oauth2-password-grant',
|
||||
GhostOauth2Authenticator
|
||||
);
|
||||
}
|
||||
};
|
@ -5,21 +5,13 @@ var AuthenticationInitializer = {
|
||||
|
||||
initialize: function (instance) {
|
||||
var store = instance.container.lookup('store:main'),
|
||||
Session = instance.container.lookup('simple-auth-session:main'),
|
||||
OAuth2 = instance.container.lookup('simple-auth-authenticator:oauth2-password-grant');
|
||||
Session = instance.container.lookup('simple-auth-session:main');
|
||||
|
||||
Session.reopen({
|
||||
user: Ember.computed(function () {
|
||||
return store.find('user', 'me');
|
||||
})
|
||||
});
|
||||
|
||||
OAuth2.reopen({
|
||||
makeRequest: function (url, data) {
|
||||
data.client_id = 'ghost-admin';
|
||||
return this._super(url, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user