【问题标题】:Meteor Accounts-Entry how to prevent an extraSignupField from being stored to the database?Meteor Accounts-Entry 如何防止extraSignupField 被存储到数据库中?
【发布时间】:2014-10-24 04:53:12
【问题描述】:

我正在使用 Meteor 的 account-entry 包来处理我的网络应用程序的登录注册操作。要将Confirm Password 字段添加到注册表单,这就是我所做的(在 CoffeeScript 中):

AccountsEntry.config
      logo: '/logo.png'
      homeRoute: 'main'
      dashboardRoute: 'main'
      profileRoute: '/profile'
      extraSignUpFields: [
        field: "confirmPassword"
        label: "Confirm Password"
        type: "password"
      ,
        field: "name"
        label: "Full Name"
        placeholder: "Full Name"
        type: "text"
        required: true
      ,
        field: "position"
        label: "Position"
        placeholder: "Developer"
        type: "text"
      ]

这种方法的问题在于:它还将confirmPassword字段保存到数据库中,这样当有人访问数据库>用户集合时,他们可以清楚地看到confirmPassword字段中每个用户的密码-即非常糟糕。

我还不知道如何解决这个问题。我认为可能有一个属性决定是否应将特定字段存储在数据库中,但我还没有弄清楚! (accounts-entrydocumentation 对我来说似乎不够详细,我不得不说:()

你们能帮我解决这个问题吗?提前非常感谢!

【问题讨论】:

标签: meteor minimongo meteor-accounts


【解决方案1】:

缺少密码确认字段是known issue with accounts-entry

另一方面,users collection 的发布功能应该只发布严格必要的字段。默认情况下,只有usernameemailsprofile会发布到客户端。

无论如何,您不应该一开始就将 confirmPassword 存储在数据库中。为此,请在返回 user 对象之前挂钩 Accounts.onCreateUser 并删除 that field

Accounts.onCreateUser(function (options, user) {
  delete user.confirmPassword;  // or: delete user.profile.confirmPassword;
  return user;
});

【讨论】:

  • 非常感谢!我怀疑这是帐户输入问题。但是你修复它的方式真的很棒!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-31
相关资源
最近更新 更多