简体   繁体   English

Meteor.js添加有关用户帐户注册的更多信息

[英]Meteor.js adding more info on user account sign up

Below is my code, but for some reason the first and last names aren't saved? 以下是我的代码,但是由于某种原因,名字和姓氏没有保存? How do I save additional info when creating a new user in Meteor? 在Meteor中创建新用户时如何保存其他信息? I'm using the accounts-password package. 我正在使用帐号密码包。

Accounts.createUser({
  email: email,
  password : password,
  profile: {firstName: firstName, lastName: lastName}
}, function (err) {
  if (err) {
    // Inform the user that account creation failed
  } else {
    // Success. Account has been created and the user
    // has logged in successfully. 
  }
});

The onCreateUser callback should return the finall user object which is about to be saved into the database. onCreateUser回调应返回将要保存到数据库中的finall user对象。 The problem you have comes from the fact that the profile data need to be hooked manually tho the user object (see meteor docs for more details): 您遇到的问题来自以下事实:需要手动将profile数据挂接到user对象(有关更多详细信息,请参见流星文档 ):

Accounts.onCreateUser(function(options, user) {
    // [...]
    if (options.profile)
        user.profile = options.profile;
    return user;
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM