I am adding admin login for Symfony2 Login Configuration. I got an error saying 'adminlogged' path not found. No matching route in your routing configuration!
Security.yml
security:
encoders:
MPW\TemplateBundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
MPW\TemplateBundle\Entity\Admin:
algorithm: sha1
encode_as_base64: false
iterations: 1
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
users:
entity: { class: TemplateBundle:User, property: email }
admin:
entity: { class: TemplateBundle:Admin, property: email }
#my_custom_hwi_provider:
# id: my_user_provider
firewalls:
secured_area:
pattern: ^/
anonymous: ~
provider: users
form_login:
login_path: user_login
check_path: login_check
default_target_path: dashboard
logout:
path: log_out
admin_secured_area:
pattern: ^/
anonymous: ~
provider: admin
form_login:
login_path: admin_login
check_path: admin_check
default_target_path: /admin_dashboard
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin-login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
Routing.yml:
user_login:
pattern: /login
defaults: { _controller: LandingPageBundle:Landing:login }
admin_login:
pattern: /admin-login
defaults: { _controller: LandingPageBundle:Landing:adminLogin }
login_check:
pattern: /logged
admin_check:
pattern: /adminlogged
User Login is working fine but the admin login feature is having an issue
You have to define a controller for your admin_check
route:
routing.yml
login_check:
pattern: /logged
admin_check:
pattern: /adminlogged
defaults: { _controller: LandingPageBundle:Landing:adminLogin } # line added
There is no controller for the login_check
route because it's managed by Symfony2:
You will not need to implement a controller for the /login_check URL as the firewall will automatically catch and process any form submitted to this URL. However, you must have a route (as shown here) for this URL, as well as one for your logout path (see Logging Out).
Source: official Symfony2 documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.