6

我按照教程进行设置 SonataAdminFosUer
FosUser 似乎可以连接和断开连接

但是对于奏鸣曲我无法访问
>my_host/web/app_dev.php/admin/dashboard
当我尝试将防火墙重定向到:my_host/web/app_dev.php/admin/login

并引发错误:
Route "admin/login" does not exist.
500 Internal Server Error - RouteNotFoundException

Routing.yml 看起来正确:

admin:
     resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
     prefix: /admin
_sonata_admin:
     resource: .
     type: sonata_admin
     prefix: /admin
soanata_user:
     resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
     prefix: /admin[/xml]

配置.yml:

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]
        sonata.block.service.text:
        sonata.block.service.action:
        sonata.block.service.rss:
sonata_admin:
    title:      Admin Panel
    templates:
        ## default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig
        ## default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Application\Sonata\UserBundle\Entity\User

安全性.yml:

firewalls:
    admin:
        pattern:      /admin(.*)
        form_login:
            provider:       fos_userbundle
            login_path:     admin/login
            use_forward:    false
            check_path:     admin/login_check
            failure_path:   null
        logout:
            path:           /admin/logout
        anonymous:    true

        # defaut login area for standard users
        main:
            pattern:      .*
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                failure_path:   null
            logout:       true
            anonymous:    true

    access_control:
             # URL of FOSUserBundle which need to be available to anonymous users
        - { path: ^/_wdt, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/_profiler, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # -> custom access control for the admin area of the URL
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        # -> end

        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Secured part of the site
        # This config requires being logged for the whole site and having the admin role for the admin part.
        # Change these rules to adapt them to your needs
        - { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

php 应用程序/控制台路由:调试:

admin_sonata_user_group_show            ANY      /admin/sonata/user/group/{id}/show
admin_sonata_user_group_export          ANY      /admin/sonata/user/group/export
sonata_user_admin_security_login        ANY      /admin[/xml]/login
sonata_user_admin_security_check        ANY      /admin[/xml]/login_check
sonata_user_admin_security_logout       ANY      /admin[/xml]/logout

如果我IS_AUTHENTICATED_ANONYMOUSLY 进入角色:
在行 - { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
我可以访问admin/dashboard,因为我没有重定向到管理员/登录,所以我认为这不是 sonataBundle 的问题。

你有什么想法吗?

非常感谢。

4

2 回答 2

3

您必须在您的内部添加路由信息app/config/routing.yml

sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin
于 2014-07-25T22:15:09.413 回答
1

全新安装后我也遇到了这个错误。

要解决它,请修改您的app/config/routing.yml并写prefix: /admin而不是prefix: /admin[/xml]soanata_user:.

于 2013-03-18T14:04:53.723 回答