为什么symfony2 fosUserBundle找不到check_path?

时间:2021-12-17 07:35:30

I'm trying to implement fosUserBundle in my symfony project.

我想在我的symfony项目中实现fosUserBundle。

I've successfully installed an configured the bundle.

我已经成功地安装了一个配置好的bundle。

But now, when I log in, I'm having this error message:

但是现在,当我登录的时候,我有一个错误信息:

You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.

您必须在安全防火墙配置中使用form_login配置防火墙要处理的检查路径。

Why is that happening ? where should i look for that pb ?

为什么会这样?我应该在哪里找那个pb ?

Thank you, you'll find below the security file:

谢谢,您可以在安全文件下面找到:

security:
    encoders:
        "FOS\UserBundle\Model\UserInterface": sha512

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

    providers:
        fos_userbundle:
            id: fos_user.user_manager
        in_memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

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

        # Firewall pour les pages de connexion, inscription, et récupération de mot de passe
        login:
            pattern:   ^/(login$|register|resetting)  # Les adresses de ces pages sont login, register et resetting
            anonymous: true                           # On autorise bien évidemment les anonymes sur ces pages !

        admin:
            switch_user:        true
            context:            user
            pattern:            /admin(.*)
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
                use_referer:    true
            logout:
                path:           /admin/logout
                target:         /login_path
    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

For the rest of the files it is very similar to the official documentation

对于其余的文件,它与官方文档非常相似

1 个解决方案

#1


0  

Did you try to delete the first line in the "access_control" section ? Because you already specified anonymous:true in you login firewall.

您是否尝试删除“access_control”部分中的第一行?因为您已经在登录防火墙中指定了anonymous:true。

#1


0  

Did you try to delete the first line in the "access_control" section ? Because you already specified anonymous:true in you login firewall.

您是否尝试删除“access_control”部分中的第一行?因为您已经在登录防火墙中指定了anonymous:true。