我正在使用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
字段保存到数据库中,以便当有人访问数据库时>用户收藏,他们可以清楚地看到每个用户&#39; <{1}}字段中的密码 - 非常糟糕。
我还不知道如何解决这个问题。我认为可能有一个属性决定一个特定的字段是否应该存储在数据库中,但我还没想到它! (confirmPassword
包documentation对我来说似乎不够详细,我不得不说:()
你们可以帮我解决这个问题吗?非常感谢提前!
答案 0 :(得分:1)
缺少密码确认字段为known issue with accounts-entry。
另一方面,users collection的发布功能应该只发布严格必要的字段。默认情况下,只有username
,emails
和profile
发布到客户端。
无论如何,您不应该将confirmPassword存储在数据库中。为此,请在返回user
对象之前挂钩Accounts.onCreateUser
并删除that field:
Accounts.onCreateUser(function (options, user) {
delete user.confirmPassword; // or: delete user.profile.confirmPassword;
return user;
});