简体   繁体   English

具有带有meteor-roles包的角色/组的组层次结构

[英]Group Hierarchy With Roles/Groups with meteor-roles package

I'm looking for a reliable, and respectable way to handle roles and groups with hierarchy in Meteor. 我正在寻找一种可靠,可敬的方式来处理Meteor中具有层次结构的角色和组。 I'm not married to the alanning:roles package and will gladly swap it out for a package that easily meets these demands. 我没有和alanning:roles包结婚,很乐意将它换成一个可以轻松满足这些要求的软件包。

The demands: 要求:

I need to be able to create an "infinite" amount of sub-groups. 我需要能够创建“无限”数量的子组。 Say I have a team (Team A) with user(s) (Bob, Jim, Anna, Daisy, Tom, Jerry) and I want some of the members to be able to have control over users underneath them, but not above. 假设我有一个团队(团队A)和用户(Bob,Jim,Anna,Daisy,Tom,Jerry),我希望一些成员能够控制他们下面的用户,但不能超过他们。 So, to best illustrate this idea I present the following tree: 所以,为了最好地说明这个想法,我提出了以下树:

  • Bob (Team A) 鲍勃(A队)
    • Jim (Division 1) 吉姆(1区)
      • Daisy (Managers) 黛西(经理)
    • Anna (Division 2) 安娜(2区)
      • Tom (Slave Drivers) 汤姆(奴隶司机)
        • Jerry (Users) 杰瑞(用户)

So my current idea for how best to handle this, is by assigning groups with cascading groups where the tree would be represented as these role/group combinations: 因此,我目前关于如何最好地处理此问题的想法是通过为具有级联组的组分配树,其中树将表示为这些角色/组组合:

  • bob : roles : ["role"], group: team_a bob:roles:[“role”],group:team_a
  • jim : roles : ["role"], group: team_a:division_1 jim:roles:[“role”],group:team_a:division_1
  • daisy : roles : ["role"], group: team_a:division_1:managers 雏菊:角色:[“角色”],组:team_a:division_1:经理
  • anna : roles : ["role"], group: team_a:division_2 anna:roles:[“role”],group:team_a:division_2
  • tom : roles : ["role"], group: team_a:division_2:slave_drivers tom:roles:[“role”],group:team_a:division_2:slave_drivers
  • jerry : roles : ["role"], group: team_a:division_2:slave_drivers:users jerry:roles:[“role”],group:team_a:division_2:slave_drivers:users

I'm not a huge fan of this structure as it doesn't really support the idea of groups very much as well as a bunch of other problems I can foresee already. 我不是这个结构的忠实粉丝,因为它不能真正支持群体的想法以及我已经可以预见的一堆其他问题。 But the only alternate I can think of would be something like this: 但我能想到的唯一替代方案是这样的:

  • bob: roles: [ bob:角色:[
    • {["role"], team_a}, {[“role”],team_a},
    • {["role"], team_a:division_1}, {[“role”],team_a:division_1},
    • {["role"], team_a:division_1:managers}, {[“role”],team_a:division_1:managers},
    • {["role"], team_a:division_2}, {[“role”],team_a:division_2},
    • {["role"], team_a:division_2:slave_drivers}, {[“role”],team_a:division_2:slave_drivers},
    • {["role"], team_a:division_2:slave_drivers:users} ] {[“role”],team_a:division_2:slave_drivers:users}]
  • jerry: roles: [ 杰里:角色:[
    • {["role"], team_a:division_2:slave_drivers:users} ] {[“role”],team_a:division_2:slave_drivers:users}]

Does this make more sense? 这更有意义吗? It seems like I would have to update every user's permissions every time I create a sub-group. 似乎每次创建子组时我都必须更新每个用户的权限。 And it seems like the amount of defined groups could increase pretty quickly. 似乎定义的组的数量可以很快增加。

If I'm way off and there's a much easier way to pull this off, I'd appreciate being pointed in the right direction. 如果我离开了,并且有一个更简单的方法来解决这个问题,我会很感激被指向正确的方向。 With these routes, it definitely feels like I'm trying to make the roles package do something its not designed to do. 有了这些路线,我肯定觉得我正在尝试让角色包做一些其他设计不做的事情。 Thank you. 谢谢。

If anyone is interested in this type of permissions management, feel free to check out the bgromadzki:meteor-teams package I've put together. 如果有人对这种类型的权限管理感兴趣,请随时查看我放在一起的bgromadzki:meteor-teams包。 Or the github page here: https://github.com/BRyeGmoney/meteor-teams 或者github页面: https//github.com/BRyeGmoney/meteor-teams

I used a similar premise as the roles package, but i switched the package's focus from roles to the groups (as in there's now a teams collection, rather than roles), which I named teams as groups seemed too loose a term. 我使用了与角色包类似的前提,但是我将包的重点从角色转移到了群组(就像现在的团队集合,而不是角色),我将团队命名为群体似乎过于宽松。 I intend to continue working on it a bit more, and appreciate any feedback as well as suggestions for what they might need. 我打算继续努力,并感谢任何反馈以及他们可能需要的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM