gpt4 book ai didi

meteor - meteor 中的重置密码问题

转载 作者:行者123 更新时间:2023-12-05 00:23:46 29 4
gpt4 key购买 nike

我向用户发送了注册电子邮件,当他输入密码和其他详细信息时,我试图重置密码,但它抛出错误

uncaught error extpected to find a document to change

enter image description here

正如你在法师中看到的

我订阅了用户记录

我的代码
this.route('enroll', {
path: '/enroll-account/:token',
template: 'enroll_page',
onBeforeAction: function() {
Meteor.logout();
Session.set('_resetPasswordToken', this.params.token);
s = this.subscribe('enrolledUser', this.params.token).wait();
}
}),

在我显示表单和提交事件之后
onSubmit: function(creds) {
var options = {
_id: Meteor.users.findOne()._id,
name: creds.name
}
var token=Session.get('_resetPasswordToken');
Meteor.call('updateUser', options, function(error, result) {
if(!error) {
Accounts.resetPassword(token, creds.password, function(error) {
if (error) {
toastr.error("Sorry we could not update your password. Please try again.");
return false;
}
else{
toastr.error("Logged In");
Router.go('/');
}
});
} else {
toastr.error("Sorry we could not update your password. Please try again.");
return false;
}
});
this.resetForm();
this.done();

return false;
}

一切正常,但 resetpassword 回调未触发,并且上述错误显示在控制台中。

我的 token 已从用户记录中删除,我可以使用登录表单登录,但

从文档
Reset the password for a user using a token received in email. Logs the user in afterwards.

重置密码后我无法自动登录,上面的错误正在抛出

我在这里想念什么?

最佳答案

this.subscribe('enrolledUser', this.params.token).wait();

在这里,您正在使用 resetPassword token 进行订阅

当您调用 Accounts.resetPassword method 该方法将重置密码并从用户记录中删除 token 。

所以你的订阅丢失了,客户端没有记录可以修改
(这就是错误 Expected to find a document to change )

而是在第一次订阅时保存用户 ID 并使用 Id 订阅用户记录

所以订阅不会丢失
path: '/enroll-account/:token',
template: 'enroll_page',
onBeforeAction: function() {
Meteor.logout();
Session.set('_resetPasswordToken', this.params.token);
s = this.subscribe('enrolledUser', this.params.token).wait();
},
onAfterAction:function(){
if(this.ready()){
var userid=Meteor.users.findOne()._id;
Meteor.subscribe("userRecord",userid);
}
}

关于meteor - meteor 中的重置密码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27590542/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com