使用Meteor Autoforms更新密码
我正在尝试创建一个帐户页面,用户可以在其中更新其个人资料信息和/或更新其密码。我目前正在将此用于表单:使用Meteor Autoforms更新密码,meteor,passwords,meteor-autoform,Meteor,Passwords,Meteor Autoform,我正在尝试创建一个帐户页面,用户可以在其中更新其个人资料信息和/或更新其密码。我目前正在将此用于表单: {{#autoForm collection="Meteor.users" doc=profile id="myAccount" type="update"}} <fieldset> <legend>My Account</legend>
{{#autoForm collection="Meteor.users" doc=profile id="myAccount" type="update"}}
<fieldset>
<legend>My Account</legend>
{{> afQuickField name="username"}}
{{> afQuickField name="profile.firstName"}}
{{> afQuickField name="profile.lastName"}}
{{> afQuickField name="emails.0.address"}}
{{> afQuickField name="emails.0.verified" class="i-checks"}}
{{> afQuickField name="password"}}
</fieldset>
<button type="submit" class="btn btn-primary">Update</button>
{{/autoForm}}
{{{#autoForm collection=“Meteor.users”doc=profile id=“myAccount”type=“update”}
我的帐户
{{>afQuickField name=“username”}
{{>afQuickField name=“profile.firstName”}
{{>afQuickField name=“profile.lastName”}
{{>afQuickField name=“emails.0.address”}
{{>afQuickField name=“emails.0.verified”class=“i-checks”}
{{>afQuickField name=“password”}
更新
{{/autoForm}
据我所知,我需要修改user Accounts.setPassword以更新用户密码。所以我想我必须使用一个钩子,但是onSubmit钩子不能用于类型更新
使用这种表单更新密码的最佳方法是什么?类似的方法是否有效:联系人表单是您表单的名称
AutoForm.hooks({
contactForm: {
onSubmit: function (insertDoc, updateDoc, currentDoc) {
if (customHandler(insertDoc)) {
this.done();
} else {
this.done(new Error("Submission failed"));
}
return false;
}
}
});
onSubmit不能与type=“update”一起使用。如果我更改提交类型,则您的建议有效。谢谢