GithubHelp home page GithubHelp logo

Comments (15)

abernix avatar abernix commented on May 31, 2024

Just moving it again from meteor/meteor#6728 (the landlord over there is the worst! 😉)

Originally in meteor/guide#196. 😄

from docs.

ffxsam avatar ffxsam commented on May 31, 2024

You know what's interesting about adding custom data to a user: you can't add anything until after the user is already created. But at creation time, you can still use profile which is incorrect. So I wrote a little routine to handle this, so I can add first name, last name, etc to profile, but it moves it to the right spot for me.

Accounts.onCreateUser((options, user) => {
  /*
   * The official Meteor Guide recommends not storing things in user.profile. So
   * this will mutate any newly created user and just put profile information at
   * the root level which is recommended. So when using Accounts.createUser,
   * go ahead and use profile, and this will handle fixing it.
   *
   * Reference: http://guide.meteor.com/accounts.html#dont-use-profile
   */
  return { ...user, ...options.profile };
});

from docs.

lorensr avatar lorensr commented on May 31, 2024

Here are places I'm seeing profile used in docs.

Is name or anything else auto-added to the profile by any of the accounts-* packages?

Accounts.emailTemplates.enrollAccount.subject = function (user) {
    return "Welcome to Awesome Town, " + user.profile.name;
};

example user doc:

  profile: {
    // The profile is writable by the user by default.
    name: "Joe Schmoe"
  },

also:

image

from docs.

stubailo avatar stubailo commented on May 31, 2024

Yes, name is added automatically by the accounts packages.

from docs.

lorensr avatar lorensr commented on May 31, 2024

@ffxsam I don't see any other places in docs saying to use profile, do you?

from docs.

ffxsam avatar ffxsam commented on May 31, 2024

Well, it's mentioned all over http://docs.meteor.com/api/accounts.html and http://docs.meteor.com/api/accounts-multi.html.

from docs.

lorensr avatar lorensr commented on May 31, 2024

It seems like that's just describing how the code works, which I wouldn't want to take out until the code changes?

from docs.

ffxsam avatar ffxsam commented on May 31, 2024

Ok, I'm now lost.. I think I've lost track of what this discussion was actually about. ;)

I think the confusion is that the Meteor Guide says to not use profile. But the docs have examples of using it. And is it being considered that profile be officially removed from the docs?

from docs.

lorensr avatar lorensr commented on May 31, 2024

I think the confusion is that the Meteor Guide says to not use profile. But the docs have examples of using it.

Since that's where the accounts packages put the name, I think we should leave some info about it in the docs. We do say:

"Do not store anything on profile that you wouldn’t want the user to edit unless you have a deny rule on the Meteor.users collection."

Maybe there are more places where we should put a similar disclaimer/recommendation?

And is it being considered that profile be officially removed from the docs?

I wouldn't remove it from docs until the code changes, at which point we'll probably just not have it be default-writeable (and remove the Guide recommendation to not use it). That would be breaking, which is why the change hasn't been made yet.

from docs.

ffxsam avatar ffxsam commented on May 31, 2024

Since that's where the accounts packages put the name

Could you elaborate on this? In what scenario does creating a user automatically populate profile.name? I've always had to manually add it, e.g.:

Accounts.createUser({ email: 'blah@blah', password: 'test', profile: { name: 'Bob' } });

from docs.

lorensr avatar lorensr commented on May 31, 2024

Don't know, I'm going by #61 (comment) 😊 accounts-facebook might be an example?

from docs.

ffxsam avatar ffxsam commented on May 31, 2024

@stubailo What's the official stance then? Can we still use profile for things like name (or split out into first/last name)? Or should that just go right onto the user object? The only advantage I see for using profile is that it doesn't require a subscription to access data inside of it. But I just wasn't sure if MDG is saying we should be careful about what we put in profile, or that we should outright not use it.

from docs.

tmeasday avatar tmeasday commented on May 31, 2024

The guide is more up-to-date than the docs, so this is the latest thinking: https://guide.meteor.com/accounts.html#dont-use-profile

from docs.

StorytellerCZ avatar StorytellerCZ commented on May 31, 2024

The docs seem to me to hint about the dangers of using profile. Should we add a link to the guide for more info or any mentions altogether then?

from docs.

filipenevola avatar filipenevola commented on May 31, 2024

I'm closing this issue because it's too old.

If you think this issue is still relevant please open a new one.

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.