Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 168 forks source link

Roles.createRole is not a function #403

Open zangab opened 2 months ago

zangab commented 2 months ago

Describe the bug

I am not sure if this is a faulty behavior or intended. I installed the package along with accounts-password and meteor vue. I followed the docs but as soon as I called Roles.createRole(...) the server threw a TypeError saying Roles.createRole is not a function.

So I dumped the Roles variable and saw that there was only a createRoleAsync function present but no createRole. My startup script is async, meaning:

Meteor.startup(async () => {
  // ...
})

The question is now: are the docs wrong? Is this intended? I saw that in the common.js file there is a createRole function present.

To Reproduce

Install

accounts-password@3.0.0
alanning:roles@4.0.0-rc.2

put this function into the server/main.js

Meteor.startup(async () => {
  Roles.createRole('admin', { unlessExists: true })
})

Expected behavior

Does not throw any error or docs update (place an info somewhere that this can happen).

Screenshots

Bildschirmfoto 2024-08-28 um 09 14 20

github-actions[bot] commented 2 months ago

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

demangejeremy commented 2 months ago

Same problem for me. I'm trying to solve this last problem before migrating to Meteor v3.

zangab commented 2 months ago

@demangejeremy The fix is actually quite easy with await Roles.createRoleAsync(...) but it's irritating if the docs state otherwise. That's why I try to reach out to some maintainers :)

demangejeremy commented 2 months ago

Thanks a lot @zangab, that's what I realized right after I sent my message. Indeed, it's confusing.