Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony2:isgrated方法返回AuthenticationCredentialsNotFoundException_Symfony_Twig - Fatal编程技术网

Symfony2:isgrated方法返回AuthenticationCredentialsNotFoundException

Symfony2:isgrated方法返回AuthenticationCredentialsNotFoundException,symfony,twig,Symfony,Twig,我的页面中有一个细枝扩展菜单,但我需要使用isgrated方法根据用户显示菜单项,但symfony2 Profiler会向我显示一个警报: 剖析者说: AuthenticationCredentialsNotFoundException:安全上下文不包含身份验证令牌。一个可能的原因可能是没有为此URL配置防火墙 在C:\xampp\htdocs\galvez_motos\app\cache\dev\classes.php行2395中 在C:\xampp\htdocs\galvez\u motos

我的页面中有一个细枝扩展菜单,但我需要使用isgrated方法根据用户显示菜单项,但symfony2 Profiler会向我显示一个警报:

剖析者说:

AuthenticationCredentialsNotFoundException:安全上下文不包含身份验证令牌。一个可能的原因可能是没有为此URL配置防火墙

在C:\xampp\htdocs\galvez_motos\app\cache\dev\classes.php行2395中 在C:\xampp\htdocs\galvez\u motos\src\GalvezMotos\AlmacenBundle\Twig\MenuExtension.php第432行中的SecurityContext->Is被授予“角色\管理员”

登录前如何使用isgrated方法

security.yml:

security:
firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false
    secured_area:
        pattern: ^/
        anonymous: ~
        form_login:
            login_path: login
            check_path: login_check
        logout:
            path: /logout
            target: /
            invalidate_session: false

access_control:
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY  }
    - { path: ^/admin, roles: ROLE_ADMIN }
    - { path: ^/, roles: ROLE_USER }

providers:
    user_db:
        entity: { class: GalvezMotos\AlmacenBundle\Entity\Usuario, property: username }

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

encoders:
    GalvezMotos\AlmacenBundle\Entity\Usuario:
        algorithm: sha1
        iterations: 1
        encode_as_base64: false
Pd:图像