2014-06-23 19:47:51 -05:00
|
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
2014-03-26 00:34:30 +01:00
|
|
|
|
2014-06-23 19:47:51 -05:00
|
|
|
var ForgottenController = Ember.Controller.extend(ValidationEngine, {
|
2014-03-26 00:34:30 +01:00
|
|
|
email: '',
|
2014-06-23 19:47:51 -05:00
|
|
|
submitting: false,
|
|
|
|
|
|
|
|
// ValidationEngine settings
|
|
|
|
validationType: 'forgotten',
|
|
|
|
|
2014-03-26 00:34:30 +01:00
|
|
|
actions: {
|
|
|
|
submit: function () {
|
|
|
|
var self = this;
|
2014-06-23 19:47:51 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2014-03-26 00:34:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ForgottenController;
|