mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
1c6216777c
Closes #3511, Closes #3512, Closes #3526 - show* methods now close existing passive notifications by default. They also now take an optional options object where existing parameters such as "delayed" and "defaultErrorText" can be passed in as well as the new "doNotClosePassive" flag. - Removed all explicit calls to notifications.closePassive except for the few places where it makes sense to call it separately.
44 lines
1.6 KiB
JavaScript
44 lines
1.6 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.showAPIError(resp, { defaultErrorText: 'There was a problem logging in, please try again.' });
|
|
});
|
|
}).catch(function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default ForgottenController;
|