Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[createUser Mutation]: Allow custom fields on user document (not .profile)? #62

Open
joncursi opened this issue May 27, 2017 · 3 comments

Comments

@joncursi
Copy link

Right now the createUser mutation only provides a profile argument where you can supply additional user info such as name, birthday, gender, etc. to store on the profile field in the user document.

However, Meteor doesn't recommend storing ANY of your user data on profile and instead recommends storing it as a first-class field on the user document.

It would be great if createUser were expanded to allow custom fields like this, so we're not forced to stick things under profile, especially when MDG doesn't recommend it.

@joncursi
Copy link
Author

joncursi commented May 27, 2017

I suppose there is a way around this.

  1. Pass the profile data in through the profile field of the mutation
  2. Create a custom hook on the server to re-arrange the data:
Accounts.onCreateUser((options, user) => {
  return {
    ...user,
    name: options.profile.name, // this pulls the name out of profile and stores it at the top level instead
  };
});

@rodcisal
Copy link

rodcisal commented May 30, 2017

@joncursi I've done exactly the same as you

@rodcisal
Copy link

rodcisal commented May 30, 2017

@joncursi My only concern regarding writing attributes at the top level is that someone might overwrite something very important ie: services
The solution they propose is doing it on the server just as you did.
https://guide.meteor.com/accounts.html#adding-fields-on-registration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants