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

Roles.getRolesForUser() returns [] (empty array) #415

Open
Berchez opened this issue Jan 31, 2025 · 3 comments
Open

Roles.getRolesForUser() returns [] (empty array) #415

Berchez opened this issue Jan 31, 2025 · 3 comments
Labels

Comments

@Berchez
Copy link

Berchez commented Jan 31, 2025

Describe the bug

TL;DR - My Roles.getRolesForUser() always returns an empty array (even on the server-side).

Hi, I read the documentation and published it:

Meteor.publish(null, function() { if (this.userId) { return Meteor.roleAssignment.find({ 'user._id': this.userId }); } else { this.ready(); } });

However, even with the publication, my Roles.getRolesForUser() calls don't return anything. Regardless of whether it's on the client or the server.

I also read the issue #296 where the guy forgot to import the publication (which is not my case).

Other methods from v3 work normally in my code. (I haven't been able to test them all yet).

Meteor.roleAssignment.find({ 'user._id': this.userId }).fetch(), normally returns my user's roles.

To Reproduce

After migrating from v1 to v2 and finally v3, I just call Roles.getRolesForUser(userId) inside a useEffect or inside a meteor method and it returns []

Expected behavior

Return a result similar to Meteor.roleAssignment.find({ 'user._id': this.userId }).fetch() when I call Roles.getRolesForUser(this.userId)

Versions (please complete the following information):

  • Meteor version: Meteor 2.16
  • Browser: Chrome v132.0.6834.111
  • Version: alanning:[email protected]
@Berchez Berchez added the bug label Jan 31, 2025
Copy link

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee your issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know

@jankapunkt
Copy link
Member

Hi @Berchez can you confirm the Meteor.roleAssignment.find({ 'user._id': this.userId }).fetch() returns the correct expected data (so we can exclude the migration as a root cause).

@Berchez
Copy link
Author

Berchez commented Jan 31, 2025

Meteor.roleAssignment.find({ 'user._id': this.userId }).fetch()

and fetchAsync works normally for me

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

No branches or pull requests

2 participants