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 167 forks source link

v2 - Roles._forwardMigrate() just removes all users from roles #348

Closed macrozone closed 2 years ago

macrozone commented 2 years ago

i am about to update an older app to v2.

i updated to 2.0.0 first and run Package['alanning:roles'].Roles._forwardMigrate(), but this basically removes everyone from all roles. Anyone has an idea what went wrong?

We have seed data that calls Roles.addUsersToRoles(userId, 'admin', Roles.GLOBAL_GROUP);,

after that i update to v2 and run Package['alanning:roles'].Roles._forwardMigrate(). Then, the admin user above has an empty role array. Also the Roles collection only contains

{ 
    "_id" : "admin", 
    "children" : [

    ]
}
macrozone commented 2 years ago

i think this is because of collection2 cleaning out the data. what is the correct schema for v2?

macrozone commented 2 years ago

the schema that can be used is:

 roles: {
    type: Array,
    optional: true,
  },
  'roles.$': {
    type: Object,
    blackbox: true,
  },