Merge pull request #4912 from jaswilli/issue-4907

Adjust reauth modal to handle removal of proxying
This commit is contained in:
Matt Enlow 2015-02-12 19:48:48 -07:00
commit 3f22cc51bf
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.
});
},