Closed danyhiol closed 4 years ago
Can you create a small test project where you can demonstrate the issue to me?
And ... Roles.subscription.ready()
is for publishing the roles, but have you also published the role-assignments? Does Meteor.roleAssignment.find().fetch()
return anything on the server and the client?
The server publication is just like in the doc:
Meteor.publish(null, function () {
if (this.userId) {
return Meteor.roleAssignment.find({ 'user._id': this.userId });
} else {
this.ready()
}
});
It was mention in the doc so since roles are now stored in a separate DB, I taught it may be necessary to publish it on the server again.
so when using Roles.subscription.ready()
it is no more necessary to use the above code?
Meteor.roleAssignment.find().fetch()
returns the roles[] (_id, role, user, scope, inheritedRoles
) on the server, but nothing on the client([]
).
I don't know how to create a test project on stackblitz for example, using meteor.
I don't know stackblitz - but I was expecting you to post the link to a github repository which I can run on my machine, debug it and change the code.
The subscription I put into the sample, which you used, only publishes the role-assignments for the user currently logged in. If you're not logged in or want to receive the permissions for another user, you'd have to generalize this publication. Have you had a look at the samples and how I had to change them to make them working with v3 of this plugin?
Yes, that is my aim, to publish only the actual user role-assignments.
I actually from meteor shell
Package['alanning:roles'].Roles._forwardMigrate2()
from version 2
that was working just fine. After the migration, roles can't be accessed from the client.
Since the documents are available on the server but not on the client, it's a problem with the publication. Please analyze the websocket transfer or create a repository which shows the problem you're facing.
Just to complete, I'm using a GraphQL server with Apollo Client. So I guess since roles are no more published automatically, I'll have to find a way to do this myself. From my readings, I've found out that GraphQL uses WebSocket replaces Meteor-DDP (Correct me if I'm wrong). I've tried normal subscription with other DB and this was returning also an empty array. So my guess is that the problem comes from it.
Solved: I forgot to import my publication file on the server...
everything works just fine on the server. But on the client, i always get:
[]
forRoles.getScopesForUser(userId);
Actually nothing works on the client. I can't getroles
orscope
from the client. I've published the role as mention in the doc forversion 3
. in the client I have the following:Wish always returns
[]
. The same goes for google chrome console