mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
01ee33643c
closes #3383 - Calls closePassive() if a new validation error is thrown to display only the latest validation error
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
/* jshint unused: false */
|
|
import ajax from 'ghost/utils/ajax';
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
|
|
var ForgottenController = Ember.Controller.extend(ValidationEngine, {
|
|
email: '',
|
|
submitting: false,
|
|
|
|
// ValidationEngine settings
|
|
validationType: 'forgotten',
|
|
|
|
actions: {
|
|
submit: function () {
|
|
var self = this,
|
|
data = self.getProperties('email');
|
|
|
|
this.toggleProperty('submitting');
|
|
this.validate({ format: false }).then(function () {
|
|
ajax({
|
|
url: self.get('ghostPaths.url').api('authentication', 'passwordreset'),
|
|
type: 'POST',
|
|
data: {
|
|
passwordreset: [{
|
|
email: data.email
|
|
}]
|
|
}
|
|
}).then(function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showSuccess('Please check your email for instructions.');
|
|
self.transitionToRoute('signin');
|
|
}).catch(function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.closePassive();
|
|
self.notifications.showAPIError(resp, 'There was a problem logging in, please try again.');
|
|
});
|
|
}).catch(function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.closePassive();
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default ForgottenController;
|