Comments (15)
Just moving it again from meteor/meteor#6728 (the landlord over there is the worst! 😉)
Originally in meteor/guide#196. 😄
from docs.
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.
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:
from docs.
Yes, name
is added automatically by the accounts packages.
from docs.
@ffxsam I don't see any other places in docs saying to use profile
, do you?
from docs.
Well, it's mentioned all over http://docs.meteor.com/api/accounts.html and http://docs.meteor.com/api/accounts-multi.html.
from docs.
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.
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.
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.
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.
Don't know, I'm going by #61 (comment) 😊 accounts-facebook
might be an example?
from docs.
@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.
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.
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.
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)
- Accounts.addEmail and Accounts.createUser - better docs / add feature / bug HOT 6
- Implementing Accounts Without Wrapping a Blaze component in React HOT 1
- Question: Use fork or local clone as the source for /code? HOT 2
- deploy/netlify PR check broken HOT 1
- Docs show 1.8 as latest version HOT 5
- CLI docs are missing --mobile-settings option for build
- Docs for v1.8 not available HOT 1
- No meteor typescript documentation HOT 2
- Add meteor publish --update to the docs HOT 4
- changes appears twice in v1.9 change log
- create basic documentation for the Accounts.createUserVerifyingEmail function HOT 2
- meteor create command is still not updated HOT 1
- Dynamic import cors issue and fix not documented HOT 1
- CSP Helmet example needs to cover hashes for modern and legacy bundles
- Document --exclude-archs flag
- Meteor commands are not orderd alphabetically HOT 1
- Meteor v2.2 API docs not available (404) HOT 2
- Cannot navigate back to new API docs from older API docs HOT 5
- Logo messed up when navigating directly to older versions of the docs HOT 2
- password_server methods documentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.