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
920 stars 164 forks source link

Roles.createRole is not a function (alanning:roles@4.0.0-alpha.3) #397

Closed carlosalvidrez closed 1 month ago

carlosalvidrez commented 1 month ago

Any hints on why this error might be happening? Using Meteor 3.0-rc1

error on boot.js TypeError: Roles.createRole is not a function

This is the code, a simple import and then the use of the .createRole method.

import { Roles } from 'meteor/alanning:roles';
Meteor.startup(function(){
    // Define roles
    Roles.createRole('user', {unlessExists: true});
github-actions[bot] commented 1 month 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

alanning commented 1 month ago

@carlosalvidrez I would guess the example code you included was being run server-side?

In the "Meteor 3 compatible" version 4.x of alanning:roles, the synchronous versions of the functions are only available client-side. So client-side, you would still use createRole but server-side the function is now named createRoleAsync:

https://github.com/Meteor-Community-Packages/meteor-roles/blob/v4.0.0-alpha.3/roles/roles_common_async.js#L83

carlosalvidrez commented 1 month ago

Ah, thank you so much, will try this right away!

carlosalvidrez commented 1 month ago

Yep, all set, thanks again @alanning !