Symfony 4重定向循环以登录多个角色

Symfony 4重定向循环以登录多个角色,symfony,security,login,redirect-loop,Symfony,Security,Login,Redirect Loop,我正在设置Symfony 4以创建新网站,但当我想使用具有多个角色的用户登录时,我会被重定向到登录页面。只有一个角色role\u用户可以登录,如何解决这个问题 配置为PHP7.2,Symfony4.2,Web服务器内置于Symfony“Server:start”中。 我试图更改安全配置,但没有任何更改 安全.yaml security: encoders: App\Entity\User: plaintext role_hierarchy: RO

我正在设置Symfony 4以创建新网站,但当我想使用具有多个角色的用户登录时,我会被重定向到登录页面。只有一个角色
role\u用户可以登录,如何解决这个问题

配置为PHP7.2,Symfony4.2,Web服务器内置于Symfony“Server:start”中。 我试图更改安全配置,但没有任何更改

安全.yaml

security:
    encoders:
        App\Entity\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        secured_area:
            # this firewall applies to all URLs
            pattern: ^/

            # but the firewall does not require login on every page
            # denying access is done in access_control or in your controllers
            anonymous: ~

            # This allows the user to login by submitting a username and password
            # Reference: http://symfony.com/doc/current/cookbook/security/form_login_setup.html
            form_login:
                # fos user bundle handles the form login
                #provider: fos_userbundle
                # The route name that the login form submits to
                check_path: fos_user_security_check
                # The name of the route where the login form lives
                # When the user tries to access a protected page, they are redirected here
                login_path: fos_user_security_login
                # Secure the login form against CSRF
                # Reference: http://symfony.com/doc/current/cookbook/security/csrf_in_login_form.html
                csrf_token_generator: security.csrf.token_manager

            logout:
                # The route name the user can go to in order to logout
                path: fos_user_security_logout
                # The name of the route to redirect to after logging out
                target: homepage

    # Easy way to control access for large sections of your site
    # Note: Only the *first* access control that matches will be used
    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/categories, role: ROLE_ADMIN }
        - { path: ^/tags, role: ROLE_ADMIN }
        - { path: ^/typewords, role: ROLE_ADMIN }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin, role: ROLE_ADMIN }
        - { path: ^/, role: ROLE_USER }
亚马尔酒店

controllers:
    resource: '../src/Controller/'
    type: annotation

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

easy_admin_bundle:
    resource: '@EasyAdminBundle/Controller/EasyAdminController.php'
    prefix: /admin
    type: annotation

我希望使用另一个
角色登录,而不是
角色用户

按层次结构,具有
角色管理
的用户自动拥有
角色用户
。因此,只需从该用户中删除
ROLE\u USER
。不确定如何从用户提供程序加载角色,请同时检查数据库中如何写入
ROLE\u ADMIN
,或者使用什么映射用户实体。(包括用户实体的映射文件以进一步了解)

尝试使用角色\u ADMIN user登录时发生了什么错误?经过一些测试,我已经更改了用户实体,现在我可以登录了。我现在使用: