使用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:"[email protected]", verified:true}],
password:"mypassword"
});
}
console.log(Meteor.users.find().fetch());
}
給我們:
[{_id: 'xxx', username:'newuser'}]
沒有電子郵件或密碼。沒有錯誤。思考?
此係統中的新用戶只能由現有用戶添加,因此我無法測試用戶提交表單。
[Accounts.createUser](http://docs.meteor.com/#/full/accounts_createuser)將「String」作爲第二個參數,而不是數組。只需將它作爲一個字符串給它,然後再驗證它。 – SylvainB
對不起,參數''電子郵件'屬性的'選項'參數 – SylvainB
@BraveKenny電子郵件的工作,但現在我得到「沒有密碼設置」錯誤嘗試登錄 –