我正在使用Meteor开发自定义登录系统,使用Accounts.forgotPassword()
函数时遇到以下错误:Uncaught Error: Must pass options.email
这就是我在相对html方面所拥有的:
<form id="recovery-form" action="action" class="form-horizontal">
<h4>Recover Password</h4>
<label>Email:</label>
<input id ="recoveryEmail" type="text" name="recoveryEmail">
<input id="sendResetInstructionbtn" class="btn btn-default loginbtn" type="submit" value="Send Reset Instructions">
</form>
这是提交功能:
'submit #recovery-form': function(event, template) {
event.preventDefault();
var validated = true;
email = trimInput(template.find('#recoveryEmail').value);
if(email === "") {
alert("Email is empty");
console.log("Email is empty");
}
if (validated) {
Session.set('loading', true);
Accounts.forgotPassword({email: email}, function(err) {
if (err) {
alert("Password Reset Failed");
console.log("Password Reset Failed" + err);
} else {
alert("Email sent");
console.log("Email sent, check email");
}
Session.set('loading', false);
});
}
return false; // Stops page from reloading
}
直到Accounts.forgotPassword函数
运行正常请协助,我有点像流星菜鸟。
答案 0 :(得分:6)
您可以尝试使用此代码,它适用于我:
var options = {};
options.email = email;
Accounts.forgotPassword(options, function(error){
if (error) {
console.log(error);
}else{
alert('Check your mailbox!');
}
});