meteor - 如何将自定义字段添加到 Meteor.users 集合?

标签 meteor user-accounts meteor-accounts meteor-useraccounts

对不起我的英语不好。我使用包 useraccounts:bootstrap 进行登录、注册等。注册后如何向 Meteor.users 集合添加任意数据。例如,我希望用户在注册后有一个值为 'false' 的字段 'status' 或带有注册时间的字段 'time'。谢谢你。

最佳答案

如果用户需要提供数据,您需要customize the UI并添加所需的字段。

在服务器上,您可以附加一个 onCreateUser()创建新用户时设置数据的回调。

import _ from 'lodash';

Accounts.onCreateUser((options, user) => {
  // add your extra fields here; don't forget to validate the options, if needed
  _.extend(user, {
    status: false,
    createdAt: new Date()
  });

  return user;
});
options参数包含来自客户端的数据。

关于meteor - 如何将自定义字段添加到 Meteor.users 集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37070438/

相关文章:

c# - asp.net core mvc 密码验证器

amazon-web-services - 带 meteor 的 AWS SES

javascript - meteor 账号登录失败

mongodb - 更新包含在 MongoDB 文档中的数组中的子文档

javascript - 使用 BlazeJS 访问文档

php - 最简单、最小的PHP账户系统

javascript - Meteor.user() 总是空的

javascript - 使用 Meteor & Handlebars 显示对象的所有或选定属性

meteor - 您将如何使用meteor.js 构建类似pinterest 的页面

sql-server-2008 - 如何将 Sysadmin 登录添加到 SQL Server?