Greetings!
I am using the accounts-password package for user accounts and trying to implement basic settings for each user. Since the accounts-password package include the useful profile field I figured this would be the perfect place to insert an array of user settings.
Here is the code I used.
var profile =
{
settings:
[{
id_: new Meteor.Collection.ObjectID(),
rule_id: “name1”,
turned_on: false,
date_created: new Date(),
date_updated:new Date()
},
{
id_: new Meteor.Collection.ObjectID(),
rule_id: “name2”,
turned_on: false,
date_created: new Date(),
date_updated:new Date()
}
]};
Accounts.createUser({username: email, email: email, password: password, profile: profile }, //callback etc etc…
I get no error on the call of Accounts.createUser but when I print the user in console --> the profile field is empty : “profile” : { }
P.S. insecure and autopublish are installed right now.
I think I am over-looking something very easy here. Any help is appreciated! Thank you Alex
@narven thanks for the reply. It shows profile as an empty object in both instances. Here is the way I solved this:
1.call Accounts.createUser(etc etc)
2.inside callback function, get current user id with Meteor.userId(); i.e. var userId = Meteor.userId();
3.call Meteor.users.update({_id:userId}, {$set:{profile:profile}}) //using profile array mentioned in original question.
Other that the fact I am making two calls to the db, is this ok to do for now. I am starting to think, Accounts.createUser() doesn’t support inserting profile information from the start… Thoughts ?