Javascript 如何在Meteor中重置帐户密码?
我正在尝试用帐户包重置密码 recover.html:Javascript 如何在Meteor中重置帐户密码?,javascript,meteor,passwords,meteor-accounts,Javascript,Meteor,Passwords,Meteor Accounts,我正在尝试用帐户包重置密码 recover.html: <template name="recoverPassword"> <div class="main-page"> <div class="profile-container"> <center> <div id="warning"></div> <div id="success"></div&g
<template name="recoverPassword">
<div class="main-page">
<div class="profile-container">
<center>
<div id="warning"></div>
<div id="success"></div>
{{#if resetPassword}}
<form id="resetPasswordForm" method="post">
<input id="resetPasswordPassword" name="password" placeholder="New Password" type="password" >
<input id="resetPasswordPasswordConfirm" name="password-confirm" placeholder="Confirm" type="password" >
<input class="btn-submit" type="submit" value="Reset">
</form>
{{else}}
<form id="sendEmail">
<div class="log-classic">
<div class="show-no-error">
<input class="log-upper-box" type="email" id="recover-email" placeholder='{{_ "global.emailHolder"}}' required>
</div>
<div class="bt-act-in">
<input type="submit" class="btn bt-signin" value="{{_ "recover.sendMail"}}"/>
</div>
</div>
</form>
{{/if}}
</center>
</div>
</div>
</template>
if(Meteor.isClient){
Template.recoverPassword.rendered = function(){
if (Accounts._resetPasswordToken){
Session.set('resetPassword', Accounts._resetPasswordToken);
}
}
Template.recoverPassword.helpers({
resetPassword: function(){
return Session.get('resetPassword') || false;
}
});
Template.recoverPassword.events({
'submit #sendEmail': function(event, template){
event.preventDefault();
template.find('#warning').innerHTML = "";
template.find('#success').innerHTML = "";
var email = template.find('#recover-email').value.trim();
Accounts.forgotPassword({email: email}, function(err) {
if (err){
if (err.message === 'User not found [403]') {
template.find('#warning').innerHTML = "There is no account registered with this email!";
}else{
console.log(err.message);
template.find('#warning').innerHTML = "We are sorry but something went wrong.";
}
}else{
template.find('#success').innerHTML = "An email has been sent";
}
});
},
'submit #resetPassword': function(e, t) {
e.preventDefault();
var password = t.find('#resetPasswordPassword').value;
var passwordConfirm = t.find('#resetPasswordPasswordConfirm').value;
console.log("pwd : " + password);
if (true){
Accounts.resetPassword(Session.get('resetPassword'), password, function(err) {
if (err) {
console.log(err.message);
template.find('warning').innerHTML = "We are sorry but something went wrong.";
} else {
console.log("wesh");
template.find('success').innerHTML = "Your password as been updated!";
Session.set('resetPassword', null);
}
});
}
}
});
}
recoverPassword模板包含在my/splash页面中。
当我输入一封未验证的电子邮件时,我会收到一条消息,表明该电子邮件不存在。否则,将随此消息一起发送邮件:
Hello,
To reset your password, simply click the link below.
http://mywebsite.herokuapp.com/#/reset-password/a7jr8WgGNRSJYHQg5x4vQhUn_qZSZEDxeJEtBgdjugD
Thanks.
然后我点击链接,进入启动页面。然后,url从我单击的url更改为/splash(换句话说,标记从浏览器的url栏中消失)
模板正确更改,我键入新密码,然后我必须禁用Adblock使其正常工作。我也一样,adblock相关的错误退出了,但是现在,当我提交带有新密码的表单时,什么都没有发生,帐户密码保持不变:/
当然,我已经在网上寻找了一些技巧/文档,但没有任何东西帮助我更进一步
有人能尽快帮我吗
非常感谢
David用户可以使用以下功能
Accounts.changePassword(OldPass, NewPass,function (err) {});