Accounts.createUser 方法不再有效。几天前一切正常,我确信我没有改变任何东西。
我有一张注册表格。点击提交后,将执行以下代码:
编辑 我忘了说这个函数是在 meteor 方法中所以它会在客户端和服务器上执行
var newUserData = {
username : post.email,
password : post.pwd,
email : post.email,
profile: {
first_name : post.first_name,
last_name : post.last_name,
register : ''
}
};
console.log('### new user data ###');
console.log(newUserData);
var newUserCreated = Accounts.createUser(newUserData, function(e){
console.log('### createuser callback ###');
console.log(e);
});
console.log(newUserCreated);
“newUserData”返回一个有效的对象。我的示例中的这个:
{
username: 'info@email.com',
password: 'mypassword',
email: 'info@email.com',
profile:
{ first_name: 'wadwad',
last_name: 'wadawd',
register: '' }
}
此控制台日志在客户端和服务器端是相同的。
createuser 回调只在客户端工作并返回:
Error: No result from call to createUser
newUserCreated 不返回任何内容 - 不在客户端也不在服务器端。
知道这个错误是什么意思吗?无法在谷歌上找到引用。
编辑 2 如果知道这一点很重要:createUser 方法到目前为止工作正常。我没有更改 createUser 所在的方法中的任何内容。我已经使用此功能创建了用户,并使用了我可以使用这些帐户登录的帐户包。
最佳答案
问题是来自 createUser 的回调。我认为这有点愚蠢。回调仅适用于客户端而不适用于服务器端 - 但是当在服务器端执行带有回调的方法时,服务器崩溃并且不会添加任何用户。
这有点奇怪,但无论如何 - 删除回调,一切都很好。
关于javascript - meteorjs Accounts.createUser 不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23037191/