Closed rich-m21 closed 4 years ago
Can you post the "roles" field from that user's database record, pls? Generally that means that a "$pull" mongodb command is being attempted on a field that is not an array.
Yes, I figured that much. Ended up doing the removal manually with an $unset directly to the field. It's really weird also cause I was passing in an array.
{ "_id" : "aMDsKA8TDFmHqxvpe", "createdAt" : ISODate("2019-09-12T16:46:07.096Z"), "services" : { "password" : { "bcrypt" : "$2a$10$uKIy536xc1cokpm7NW0nTuGnaFLdQcrH0gHUAcgifVY8SwiLFC66e" } }, "username" : "TestRoleA", "emails" : [ { "address" : "richmerren@gmail.com", "verified" : false } ], "roles" : { "qa" : [ "visibility", "live" ] } }
I think the function documentation is misleading. Since that user record uses "groups", you need to also pass the target group to Roles.removeUsersFromRoles(data.userId, currentRoles, 'qa')
.
Not passing a group could indicate you want to remove the user from those roles in any group but that's not the way the code works today since it still supports library users who don't use groups at all: https://github.com/alanning/meteor-roles/blob/master/roles/roles_common.js#L227-L232
I think I just published a package where you should get a better error message in this case.
I'm trying to remove users in roles using removeUsersFromRoles but get the mongo error on title Meteor version 1.8.1 alanning:roles@1.2.16
currentRoles prints out
and isArray prints out true Help!