Here is my goal: I have an enrollment page.
Template['Users.enrollment'].events({
'click button[type="submit"]': function (e, template) {
e.preventDefault();
if (AutoForm.validateForm('enroll-account-form')) {
var password = $(template.find('input[name="password"]')).val();
var token = Session.get('_resetToken');
var user = Meteor.users.findOne({
"services.password.reset.token": token
});
Accounts.resetPassword(token, password)
.then(function () {
return Meteor.promise('updateInvitations', user._id)
})
.then(function () {
return Meteor.promise('initializeUserProfile', user._id);
})
.catch(function (err) {
// want to rollback here
})
}
}
});
How can I pull off a rollback here? I tried something like this:
var rollbackUser = Meteor.users.findOne({ "services.password.reset.token": token });
// ...
.catch(function (err) {
Meteor.users.update(userId, rollbackUser);
});