0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -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:
Jason Williams 2015-02-13 01:40:13 +00:00
parent f073e10221
commit 6cc715d41b
2 changed files with 29 additions and 5 deletions

View file

@ -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',
authenticator: 'simple-auth-authenticator:oauth2-password-grant',
validationType: 'signin',
identification: Ember.computed('session.user.email', function () {
return this.get('session.user.email');
}),
@ -14,15 +18,34 @@ export default SigninController.extend({
appController.set('skipAuthSuccessHandler', true);
this._super().then(function () {
this._super(this.getProperties('identification', 'password')).then(function () {
self.send('closeModal');
self.notifications.showSuccess('Login successful.');
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 () {
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 () {
this.send('validateAndAuthenticate');
}

View file

@ -11,8 +11,9 @@ var SigninController = Ember.Controller.extend(SimpleAuth.AuthenticationControll
data = model.getProperties('identification', 'password');
this._super(data).catch(function () {
// If simple-auth's authenticate rejects we need to catch it
// to avoid an unhandled rejection exception.
// 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.
});
},