FriendsOfSymfony / FOSUserBundle路由

时间:2014-03-15 17:58:19

标签: symfony

Hy大家:) 好吧,我安装了fosuserbundle,我做了所有的配置,但当我输入我的用户名和密码,我得到  *找不到“GET /”的路线(来自//..../ web / app_dev.php / login“)*

那是我的security.yml:

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

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
        logout:    true
        anonymous: true
        #http_basic:
        #    realm: "Secured Demo Area"

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

我的UserBundle / Ressources / config / routing.yml

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
     resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
     prefix: /profile

我的app / config / routing.yml:

sdz_blog:
    resource: "@SdzBlogBundle/Resources/config/routing.yml"
    prefix:   /blog

_user_bundle:
    resource: "@SdzUserBundle/Resources/config/routing.yml"

请帮助我,我尝试了很多次:(

1 个答案:

答案 0 :(得分:2)

默认情况下,成功登录后,FosUserBundle会重定向到/。如果您在此处显示的是您拥有的唯一路线,则没有与此模式匹配的路线,因为它们都是前缀(主要路线为/blog)。

在命令行中运行php app/console router:debug并检查您是否有任何与模式/匹配的路由。

如果没有,您可以创建一个或更改FosUserBundle的默认重定向,如下所示:

# app/config/security.yml
security:
    firewalls:
        main: # or any other firewall name
            form_login:
                default_target_path: # Your route here

有关详细信息,请查看:

http://symfony.com/doc/current/reference/configuration/security.html#redirecting-after-login