-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[Feature] Be able to define default user fields published on login #11118
[Feature] Be able to define default user fields published on login #11118
Conversation
…ds published on user login - this is implemented in the same way of the Autopublish package in conjunction with Accounts.addAutopublishFields()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition, thanks. I'm requesting a change in the format 😉
@filipenevola Hope it fits now. I think that replacing the default projection makes more sense than extending it (which would have to deal with mixed projections). WDYT? |
4b3d2bf
to
ee2f65d
Compare
@menelike I don't know why CircleCI is trying to run the tests in your account and not at Meteor org. Could you create a new branch and a new PR? Sometimes CircleCI get lost :( |
…faultPublishFields(object) Instead of extending the default projection it is overridden. Otherwise a check for mixed projections would have been necessary. In addition, replacing the default projection gives the user full control over the result.
ee2f65d
to
78ea663
Compare
I was able to work around the issues with circleCI (bugs on their side), all tests have passed, we should be good to go. |
Cherry-picked to 1.12 |
@filipenevola I'm a little confused. What's the difference between |
Hi @santiagopuentep, it's used specific for the publication and not for the finds as a whole. See the diff below, in the previous code Meteor was always publishing 3 specific fields: |
Hi @menelike Is this the correct syntax for how to use this update? Accounts.setDefaultPublishFields({username: 1, profile: 1, emails: 1, 'foo.bar': 1});
// or
Accounts.setDefaultPublishFields({'do.not.publish.this': -1}); It would be good to put these updates in the accounts docs: https://docs.meteor.com/api/accounts.html Also, I'm uncertain if the defaults for the Would this update change the behavior of calling data from @filipenevola if you know how these updates work, it would be great if you could share them too. In the Meteor v1.12 update, this is not specified as a breaking change, but it would be if the previous defaults have changes. |
Hi @mullojo
Yes.
Absolutely!
I've written a comment in the linked thread. Generally speaking |
We had a lot of handling added in our app to manage that race condition that the other fields are not yet available for the UI to check. Thanks for this, @menelike. |
This removes the limitation described in https://docs.meteor.com/api/accounts.html
How to be used
Since this replaces the default projection the user has to add
profile
,username
, andprofile
to the projection to keep the old behavior.Motivation
I think that writing an additional subscription just for the sole purpose to fetch additional fields, is cumbersome and degrades the performance for no reason.
Background
In our scenario, a logged-in user has additional fields that are not part of
profile
. Those fields are needed to determine the state and the permissions of the user. In the UI, after the login has succeeded, the user will be redirected to the primary route for logged-in users - this then checks for the appropriate permission. At that point, the custom subscription used to fetch all the user data has not finished yet. As a result, the user will be redirected back to the "you are not logged in" page.tl;dr
It helps with race conditions where fields are missing after login.