我正在尝试登录两种类型的用户'用户' '和老师'在symfony中,但我仍然会收到此错误:Unable to find the controller for path "/user/login_check". Maybe you forgot to add the matching route in your routing configuration?
这是Security.yml
安全性: 编码器: AUI \包\ UserBundle \实体\老师: 算法:md5 encode_as_base64:true 迭代:1
AUI\Bundle\UserBundle\Entity\Student:
algorithm: md5
encode_as_base64: true
iterations: 1
role_hierarchy:
ROLE_TEACHER: ROLE_STUDENT
ROLE_SUPER_TEACHER: ROLE_TEACHER
ROLE_ADMIN: [ ROLE_SUPER_TEACHER, ROLE_ALLOWED_TO_SWITCH ]
providers:
#property: the field you want to use in the login, email or username=> email was chosen here
admin_area:
name: admin_security
entity: { class: AUIUserBundle:Teacher, property: email }
student_area:
name: student_security
entity: { class: AUIUserBundle:Student, property: username }
firewalls:
admin_area:
pattern: ^/
anonymous: ~
provider: admin_security
form_login:
login_path: login
check_path: login_check
default_target_path: /admin/admin_panel
logout:
path: /admin_logout
target: /login
student_area:
pattern: ^/user
provider: student_security
form_login:
login_path: /user/login
check_path: student_login_check
default_target_path: /index
logout:
path: /student_logout
target: /student_login
这是routing.yml
login:
pattern: login
defaults: { _controller:AUIUserBundle:Security:Login}
login_check:
path: login_check
logout:
path: /admin_logout
student_login:
pattern: /user/login
defaults: { _controller:AUIUserBundle:Security:StudentLogin}
student_login_check:
path: /user/login_check
student_logout:
path: /student/logout
答案 0 :(得分:1)
您错过了routing.yml
应该是这样的:
student_login_check:
path: /user/login_check
defaults: { _controller: AUIUserBundle:Security:StudentLoginCheck }
当然AUIUserBundle:Security:StudentLoginCheck
只是一个例子
答案 1 :(得分:0)
我解决这个问题的方法是让框架处理一种类型用户的登录,然后我手动编程其他登录,这意味着我编写了'logincheckAction'。找不到更好的方法来做到这一点。所有其他方式对我来说都失败了