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

Role permissions don't work with meteor-roles v3 #305

Open
leoncvlt opened this issue Apr 2, 2020 · 0 comments
Open

Role permissions don't work with meteor-roles v3 #305

leoncvlt opened this issue Apr 2, 2020 · 0 comments

Comments

@leoncvlt
Copy link

leoncvlt commented Apr 2, 2020

I don't think the roleRequired options works anymore with the latest version of the alanning:roles package released a few months ago. As part of the update, they moved roles to a separate collection - I assume restivus still checks the roles on the user document, but since they are not there anymore it fails saying the user does not have the required permissions even if it does have the correct role.

A workaround for this is to check the role manually in the action:

Api.addRoute("private", {
  post: {
    authRequired: true,
    // roleRequired: "admin",
    action: function() {
      if (Roles.userIsInRole(this.userId, "admin")) {
        // user has admin role, do your things
        return 200;
      } else {
        return 401;
      }
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant