mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Adjust reauth modal to handle removal of proxying
Closes #4907. - The modal signin no longer inherits from the signin page controller to simplify the interaction with simple-auth.
This commit is contained in:
parent
5ea14118c8
commit
691f22596e
2 changed files with 29 additions and 5 deletions
|
@ -1,8 +1,12 @@
|
||||||
import SigninController from 'ghost/controllers/signin';
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
||||||
|
|
||||||
export default SigninController.extend({
|
export default Ember.Controller.extend(SimpleAuth.AuthenticationControllerMixin, ValidationEngine, {
|
||||||
needs: 'application',
|
needs: 'application',
|
||||||
|
|
||||||
|
authenticator: 'simple-auth-authenticator:oauth2-password-grant',
|
||||||
|
|
||||||
|
validationType: 'signin',
|
||||||
|
|
||||||
identification: Ember.computed('session.user.email', function () {
|
identification: Ember.computed('session.user.email', function () {
|
||||||
return this.get('session.user.email');
|
return this.get('session.user.email');
|
||||||
}),
|
}),
|
||||||
|
@ -14,15 +18,34 @@ export default SigninController.extend({
|
||||||
|
|
||||||
appController.set('skipAuthSuccessHandler', true);
|
appController.set('skipAuthSuccessHandler', true);
|
||||||
|
|
||||||
this._super().then(function () {
|
this._super(this.getProperties('identification', 'password')).then(function () {
|
||||||
self.send('closeModal');
|
self.send('closeModal');
|
||||||
self.notifications.showSuccess('Login successful.');
|
self.notifications.showSuccess('Login successful.');
|
||||||
self.set('password', '');
|
self.set('password', '');
|
||||||
|
}).catch(function () {
|
||||||
|
// if authentication fails a rejected promise will be returned.
|
||||||
|
// it needs to be caught so it doesn't generate an exception in the console,
|
||||||
|
// but it's actually "handled" by the sessionAuthenticationFailed action handler.
|
||||||
}).finally(function () {
|
}).finally(function () {
|
||||||
appController.set('skipAuthSuccessHandler', undefined);
|
appController.set('skipAuthSuccessHandler', undefined);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validateAndAuthenticate: function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// Manually trigger events for input fields, ensuring legacy compatibility with
|
||||||
|
// browsers and password managers that don't send proper events on autofill
|
||||||
|
$('#login').find('input').trigger('change');
|
||||||
|
|
||||||
|
this.validate({format: false}).then(function () {
|
||||||
|
self.notifications.closePassive();
|
||||||
|
self.send('authenticate');
|
||||||
|
}).catch(function (errors) {
|
||||||
|
self.notifications.showErrors(errors);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
confirmAccept: function () {
|
confirmAccept: function () {
|
||||||
this.send('validateAndAuthenticate');
|
this.send('validateAndAuthenticate');
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,9 @@ var SigninController = Ember.Controller.extend(SimpleAuth.AuthenticationControll
|
||||||
data = model.getProperties('identification', 'password');
|
data = model.getProperties('identification', 'password');
|
||||||
|
|
||||||
this._super(data).catch(function () {
|
this._super(data).catch(function () {
|
||||||
// If simple-auth's authenticate rejects we need to catch it
|
// if authentication fails a rejected promise will be returned.
|
||||||
// to avoid an unhandled rejection exception.
|
// it needs to be caught so it doesn't generate an exception in the console,
|
||||||
|
// but it's actually "handled" by the sessionAuthenticationFailed action handler.
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue