【发布时间】:2015-05-08 00:04:31
【问题描述】:
使用simple schema 和accounts-password。我正在尝试在启动时添加初始帐户,但未显示电子邮件和密码。
Schemas.User = new SimpleSchema({
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/
},
emails: {
type: [Object],
optional: true
},
"emails.$.address": {
type: String,
regEx: SimpleSchema.RegEx.Email
},
"emails.$.verified": {
type: Boolean
},
profile: {
type: Schemas.UserProfile,
optional: true
}
});
和
Meteor.startup(function () {
Meteor.users.remove({});
if (Meteor.users.find().count() == 0) {
Accounts.createUser({
username: "newuser",
emails: [{address:"test@test.com", verified:true}],
password:"mypassword"
});
}
console.log(Meteor.users.find().fetch());
}
给我们:
[{_id: 'xxx', username:'newuser'}]
没有电子邮件或密码。没有错误。想法?
此系统中的新用户只能由现有用户添加,所以我一直无法测试用户提交表单。
【问题讨论】:
-
Accounts.createUser 将
String作为第二个参数,而不是数组。只需将电子邮件作为字符串给它,然后验证它。 -
抱歉,不是参数,
email属性为options参数 -
@BraveKenny 对电子邮件有效,但现在我在尝试登录时遇到“未设置密码”错误
标签: meteor schema meteor-accounts