1
当用户从使用useraccounts:core
包生成的表单中注册(第一个用户)时,我们如何自动创建第二个用户?在Meteor.JS创建第一个用户时创建第二个用户
运行从Accounts.onCreateUSer
内的Accounts.createUser
导致错误Exception while invoking method 'ATCreateUserServer' TypeError: Cannot read property '_id' of undefined
Accounts.onCreateUser(function(options, user) {
// Create Primary User
if(!user.type) {
// Set user.type as 'user'
user.type = 'user'
// Create Secondary User
Accounts.createUser({
username: options.profile.slaveName,
password: options.profile.slaveName,
type: 'slave',
profile: {
firstName: user.profile.firstName,
lastName: user.profile.lastName
}
})
user.profile = options.profile
return user
}
// Create Secondary User
if(user.type == 'slave') {
user.profile = options.profile
return user
}
});