Comments (7)
Hi Juan, thanks for the report. I just tried with the example roles app and it doesn't seem to exhibit this behavior. Could you please double-check that nothing else in your app that is publishing the user data?
Here's an online version of the example app: http://roles.meteor.com/
While not signed in, if you open the console and enter Meteor.users.find().fetch()
you will see an empty array as the result.
Meteor.users.find().fetch()
-> []
from meteor-roles.
Hey Alan, Yes, indeed if you run Meteor.users.find(), it will report only one user. But that's not the case that I'm referring to. I'm talking about the times that publish is called with an undefined user. This happens multiple times. Try the following snippet of code inserted in the server code to see that publish is called with an undefined user.
The reason that Meteor.users.find() reports only one user is that a subsequent publish with a defined userId is triggered soon after, thus restoring the single user case by the time you have the chance to type that query.
See the attached code below out of accounts-base. You will see that they guard against the undefined user case.
Thanks!
-Juan
// Report when publish is called with undefined user. Meteor.publish(null, function () { var userId = this.userId; if (!userId) { //console.log("Publish invoked with undefined userId!"); throw Error ("Publish invoked with undefined userId! (Benign. Debugging.)"); } return undefined; });
Code from accounts-base showing guard for undefined user:
https://github.com/meteor/meteor/blob/devel/packages/accounts-base/accounts_server.js
// Publish the current user's record to the client. Meteor.publish(null, function() { if (this.userId) { return Meteor.users.find( {_id: this.userId}, {fields: {profile: 1, username: 1, emails: 1}}); } else { return null; } }, /*suppress autopublish warning*/{is_auto: true});
from meteor-roles.
Actually I think you misunderstood my comment. I'm trying to reproduce the issue of all users being published but if you run the example app without signing in, it does not publish all users, even though this.userId
is not set.
Can you put together a simple repro that illustrates the problem, please?
from meteor-roles.
Hey Alan, Sorry, I can't seem to reproduce. I inserted the publish code above into the party example and I do indeed see it invoked multiple times with this.userId==undefined. However, a Meteor.users.find({_id:userId}) inserted in that code returns an empty cursor. Not sure now why I had concluded earlier that it was returning otherwise. (And it looks like the guard in accounts_server.js is unnecessary.) Sorry for the confusion.
from meteor-roles.
No worries. I've had many instances where I thought one thing was the issue but a repro ended up identifying something else.
Since it is still happening in your app, I'd suggest commenting out your publish functions and adding them back in one-at-a-time and see if that helps track it down. May also be something re: Allow/Deny rules if you have any on users
.
Closing for now. Feel free to re-open if it does turn out to be something in Roles
.
from meteor-roles.
Hey Alan, To be clear, the extra publish invocations with undefined user are not specific to my app. They happen in the Parties app too. There's some extra triggering that happens in Meteor.
from meteor-roles.
Understood. I was referring to the sending of user data to the client even
when this.userId
is unset. (Although perhaps I misunderstood your
original bug report and you just meant that the publish function itself was
being triggered when you weren't expecting it?)
FYI, the triggering of the publish function is expected behavior. When the
name
argument is null
the publish func will be run immediately for all
connected clients. It will run again whenever the logged in user changes.
On Tue, Aug 5, 2014 at 5:28 PM, Juan Pineda [email protected]
wrote:
Hey Alan, To be clear, the extra publish invocations with undefined user
are not specific to my app. They happen in the Parties app too. There's
some extra triggering that happens in Meteor.—
Reply to this email directly or view it on GitHub
#47 (comment)
.
from meteor-roles.
Related Issues (20)
- _roles publication doesn't publish Meteor.roles in v3
- v2 - Roles._forwardMigrate() just removes all users from roles HOT 2
- API docs linked to old version of codes HOT 1
- getUsersInRole reactivity? HOT 1
- getScopesForUser is not in documentation HOT 1
- How to run migration script from V1 -> V3 HOT 3
- Exception on subscription: $in needs an array.
- Support new Meteor async API (Meteor 2.8+) HOT 2
- Defaut publication uses only user._id, but no index is created on that field only HOT 2
- cannot add data into role-assignment HOT 3
- Meteor.roleAssignment, error: Property 'roleAssignment' does not exist on type 'typeof Meteor'. HOT 5
- Weird issue with role-assignement.. HOT 2
- Upgrading from 3.4.0 to 3.5.0 introduces 6x node "UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'isCalledFromAsync' of undefined" warnings. HOT 1
- TypeError: Cannot set property 'isCalledFromAsync' of undefined ... HOT 4
- Improve community standards HOT 1
- Add code quality tools HOT 2
- Add selector to Roles.getUsersInRole HOT 2
- forwardMigrate2 tries to drop unset index HOT 1
- Add new function to change scope of existing role assignment HOT 1
- addRolesToParent -> Reset inheritance as unwanted roles may still be connected 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 meteor-roles.