【问题标题】:EasyAdminBundle - List of users by role and groupEasyAdminBundle - 按角色和组列出的用户列表
【发布时间】:2020-02-02 19:57:30
【问题描述】:

我正在尝试使用 EasyAdminBundle (https://github.com/EasyCorp/EasyAdminBundle) 来管理我的项目的管理部分。

我目前正在做用户列表,效果很好。我得到所有现有用户的列表

但是,用户都被分配到组中,并且在这些组中存在“主管”。我想做的是这些“ROLE_SUPERVISOR”是对用户管理页面的访问,但他们只能看到同一组的用户。

总结一下我想要的: - 我(ROLE_SUPER_ADMIN):我想查看所有现有用户 - ROLE_SUPERVISOR:查看与他们同组的所有用户。

这可能吗?

我的 EasyAdminBundle 配置文件:

easy_admin:
  site_name: '<img height="65px" src="../img/logo.png" />'
  user:
    display_name: true
    name_property_path: 'username'
    display_avatar: false
  design:
    brand_color: '#7C1AE8'
    menu:
      - { entity: 'User', css_class: 'menu--user', icon: 'user', role: [ROLE_SUPERVISEUR, ROLE_SUPER_ADMIN] }
  entities:
    User:
      class: App\Entity\User
      label: 'Utilisateurs'
      list:
        title: "Liste des utilisateurs"
        fields:
          - email
          - { property: 'username', label: "Nom d'utilisateur" }
          - { property: 'group.name', label: "Groupe" }
          - { property: 'lastLogin', label: "Dernière connexion", format: 'd/m/Y H:i:s', type: 'datetime' }
        sort: 'group.name'

【问题讨论】:

    标签: symfony symfony4 easyadmin


    【解决方案1】:

    item_permission

    easy_admin:
        ...
        entities:
            Product:
                list:
                    # set this option to an empty string or array to unset the global permission for this entity
                    item_permission: ''
            Employees:
                list:
                    # this completely overrides the global option (both options are not merged)
                    item_permission: ['ROLE_SUPER_ADMIN', 'ROLE_HUMAN_RESOURCES']
    

    参见文档https://symfony.com/doc/master/bundles/EasyAdminBundle/book/list-search-show-configuration.html#security-and-permissions

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多