fast-render looses user document during call to Accounts.resetPassword()
MichaelJCole opened this issue · 1 comments
Hi, thanks for all your awesome packages. I had to stop using fast-render because of this issue:
Error: Expected to find a document to change
I got when running the 'click button[type="submit"]' event in this code:
// Route for link
Router.route('enrollExpert', {
path: '/enroll-expert/:token',
onBeforeAction: function () {
Session.set('_resetPasswordToken', this.params.token);
this.next();
},
waitOn: function () {
// The user is not logged in.
return Meteor.subscribe('enrolledExpert', this.params.token);
},
data: function () {
return Meteor.users.findOne({
'services.password.reset.token': this.params.token
});
},
onAfterAction:function(){
if(this.ready()){
// The user is now logged in. Get profile.
Meteor.subscribe('myProfile');
}
}
});
if (Meteor.isClient) {
// Template helpers
Template.enrollExpert.events({
'click button[type="submit"]': function (e, template) {
e.preventDefault();
if (AutoForm.validateForm('EnrollExpertForm')) {
var password = AutoForm.getFieldValue('password', 'EnrollExpertForm');
var token = Session.get('_resetPasswordToken');
console.log('starting password reset' + token + ' ' + password + ' ' + name);
Accounts.resetPassword(token, password, function (err) {
console.log('password set continuing');
console.log(err);
Router.go('home');
});
}
}
});
}
Schema.EnrollExpert = new SimpleSchema({
password: {
type: String,
optional: false,
min: 8
},
passwordCheck: {
type: String,
optional: false,
min: 8,
custom: function () {
if (this.value !== this.field('password').value) {
return 'noMatch';
}
}
}
});
Schema.EnrollExpert.messages({
noMatch: 'Passwords must match',
});
The Accounts.resetPassword() callback never get's called.
meteor remove meteorhacks:fast-render
fixes it, and the callback get's called. I haven't had the easiest time building this part, so maybe I missed something.
Thanks!
I can confirm @MichaelJCole 's findings above. Fast-render prevents proper execution of client-side Accounts.onLogin(), as the result of Accounts.resetPassword(), throwing an error:
Uncaught Exception: expected to find a document to change
See more: http://stackoverflow.com/questions/27590542/resetpassword-issues-in-meteor