0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/controllers/forgotten.js

35 lines
1.2 KiB
JavaScript
Raw Normal View History

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;
this.toggleProperty('submitting');
this.validate({ format: false }).then(function () {
self.user.fetchForgottenPasswordFor(this.email)
.then(function () {
self.toggleProperty('submitting');
self.notifications.showSuccess('Please check your email for instructions.');
self.transitionToRoute('signin');
})
.catch(function (resp) {
self.toggleProperty('submitting');
self.notifications.showAPIError(resp, 'There was a problem logging in, please try again.');
});
}).catch(function (errors) {
self.toggleProperty('submitting');
self.notifications.showErrors(errors);
});
}
}
});
export default ForgottenController;