FriendsOfSymfony/FOSUserBundle 路由 [英] FriendsOfSymfony / FOSUserBundle routing

查看:23
本文介绍了FriendsOfSymfony/FOSUserBundle 路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)好吧,我安装了 fosuserbundle 并完成了所有配置,但是当我输入用户名和密码时,我得到了*没有找到GET/"的路由(来自//..../web/app_dev.php/login")*

Hy everybody :) well i installed fosuserbundle and i did all the configurations but when i enter my username and password i get *No route found for "GET /" (from //..../web/app_dev.php/login")*

那是我的 security.yml:

Well that's my 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

My 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 :

My app/config/routing.yml :

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

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

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

Please help me,i tried a lot of times :(

推荐答案

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

By default, after a successful login, FosUserBundle redirects to /. If what you show here are the only routes that you have, then there is no route that will match this pattern since they are all prefixed (with /blog for the main ones).

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

In the command line run php app/console router:debug and check if you have any route that matches the pattern /.

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

If not, you can either create one or change the default redirection of FosUserBundle like this:

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

有关更多详细信息,您可以查看:

For more details you can check:

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

这篇关于FriendsOfSymfony/FOSUserBundle 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆