如何在 JHipster 应用程序中显示特定角色的视图或数据

How to show views or data for specific roles in JHipster application

我在我的 JHipster 应用程序中添加了一个新角色。我可以将角色分配给用户,并可以使用新的 "has-authority"(旧版本中的 "has-role")标记来限制具有不同角色的用户的访问权限。但是如何限制几个角色的菜单项呢? 我尝试了 "has-authirity="ROLE_X ROLE_Y" 和 "has-authirity="ROLE_X | ROLE_Y" 但其中 none 有效。有没有办法指定多个 role/authority 或者我真的需要为每个角色加倍编码?

在 authority.directive.js 中,您可以看到要使用的指令是 has-any-authorithy 并且它使用 Principal.hasAnyAuthority() 接受 一个字符串数组 作为参数。这是您应该传递给指令的内容。