For those who pay close attention, you might have notice that work has resumed on alanning:roles
package under the stewardship of Meteor Community Packages, which culminated in release of long overdue second version.
Since this is v2, there are breaking changes:
Migration to 2.0
In meteor-roles 2.0, functions are mostly backwards compatible with 1.0, but roles are stored differently in the database. To migrate the database to new schema, run Meteor._forwardMigrate()
on the server:
meteor shell > Package[‘alanning:roles’].Roles._forwardMigrate()
Changes between 1.0 and 2.0
Here is the list of important changes between meteor-roles 1.0 and 2.0 to consider when migrating to 2.0:
- New schema for
roles
field andMeteor.roles
collection. - Groups were renamed to scopes.
- Scopes are always available, if you do not specify a scope, role is seen as a global role.
-
GLOBAL_GROUP
is deprecated and should not be used anymore (just do not specify a scope, or usenull
). -
getGroupsForUser
is deprecated,getScopesForUser
should be used instead. - Functions which modify roles are available both on the client and server side, but should be called on the client side only from inside Meteor methods.
-
deleteRole
can now delete role even when in use, it is automatically unset from all users. - Functions
addRolesToParent
andremoveRolesFromParent
were added. -
addUsersToRoles
andsetUserRoles
now require that roles exist and will not create missing roles automatically. - All functions work with 1.0 arguments, but in 2.0 accept extra arguments and/or options.
Changes
v2.0.1
- Wrap localStorage in try/catch to avoid crash when disabled. Port fix from v1 branch. #182
v2.0.0
- Rewrite with the new schema for
roles
field andMeteor.roles
collection. - Support for roles hierarchies.
- Groups were renamed to scopes.
- Groups/scopes are always available, if you do not specify a scope, role is seen as a global role.
-
GLOBAL_GROUP
is deprecated and should not be used anymore (just do not specify a scope, or usenull
). -
getGroupsForUser
is deprecated,getScopesForUser
should be used instead. - Functions which modify roles are available both on the client and server side, but should be called on the client side only from inside Meteor methods.
-
deleteRole
can now delete role even when in use, it is automatically unset from all users. - Functions
addRolesToParent
andremoveRolesFromParent
were added. -
addUsersToRoles
andsetUserRoles
now require that roles exist and will not create missing roles automatically. - All functions work with 1.0 arguments, but in 2.0 accept extra arguments and/or options.
Going forward
There have also been updates to v1 and we will accept PRs for v1 and v2, but work has started on v3, which is primarily focused on code modernization and removal of underscore.