2015-11-06 67 views
0

我的工作與流星自定義登錄系統上,我遇到了以下錯誤使用Accounts.forgotPassword()功能時:Uncaught Error: Must pass options.email流星:必須通過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本功能離子

請協助,我有點流星noob。

回答

6

你可以試試這個代碼,它爲我工作:

var options = {}; 
options.email = email; 
Accounts.forgotPassword(options, function(error){ 
    if (error) { 
    console.log(error); 
    }else{ 
    alert('Check your mailbox!'); 
    } 
}); 
相關問題