我有2个捆绑包,路由文件app/config/routing
是:
shop_admin:
resource: "@ShopAdminBundle/Resources/config/routing.yml"
prefix: /admin
shop_desktop:
resource: "@ShopDesktopBundle/Resources/config/routing.yml"
prefix: /
ShopDesktopBundle
的路由文件是:
login:
pattern: /login
defaults: { _controller: ShopDesktopBundle:User:login }
login_check:
pattern: /login_check
ShopAdminBundle
的路由文件是:
admin_login:
path: /login
defaults: { _controller: ShopAdminBundle:Login:login }
admin_login_check:
path: /login_check
security.yml
:
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
user_secured_area:
pattern: ^/
form_login:
login_path: login
check_path: login_check
username_parameter: _username
password_parameter: _password
logout:
invalidate_session: true
path: shop_logout_user
target: /
anonymous: true
admin_secured_area:
pattern: ^/admin
form_login:
login_path: /admin/login
check_path: /admin/login_check
username_parameter: _username
password_parameter: _password
anonymous: true
当{I}尝试在ShopDesktopBundle
上进行身份验证时,ShopAdminBundle
的身份验证工作正常。我收到错误:Unable to find the controller for path "/admin/login_check". The route is wrongly configured.
我认为问题出在我的文件security.yml
中。你能帮我吗? Thx提前
答案 0 :(得分:2)
首先改变防火墙的位置。 user_secured_area
适合所有路线,而且永远不会发送admin_secured_area
。我相信它会解决你的问题。
firewalls:
admin_secured_area:
pattern: ^/admin
...
user_secured_area:
pattern: ^/
...