Implement user settings with meteor-accounts package

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 :slight_smile: Alex

When you do on the console

Meteor.user()

what does it show?

Also try on the terminal meteor shell, Meteor.users.find().fetch()

what does it show?

@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 ?

Yes it supports, im also using something similar to what ur doing.

Have you check if you have permissions to update users data? from the client?

Meteor.users.deny({ update: function() { return true; } });

or try to do an update throught the console on one of the users

something like

Meteor.users.update(someid, { $set: {'profile.kill':'godmode'}});

Here are you running that Accounts.createUser ??? server or client?

Right now client, but i will make sure to make a server side method :wink:

Can you update successfully through the console?

Have a look at the bottom of this page https://github.com/awatson1978/meteor-cookbook/blob/master/cookbook/accounts.md

https://github.com/copleykj/socialize-user-profile might be another source of inspiration.

i, scott stolinski of level up create a expert tutorial for accounts, search in youtube level up meteor accounts, and see to Accounts.config section