Symfony2 Admin Failed to find route path

I am adding admin login for Symfony2 login configuration. I got the error "adminlogged" not found. There is no suitable route in your routing configuration!

enter image description here

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 works fine, but login function has problem

+3


source to share


1 answer


You must define a controller for your route admin_check

:

routing.yml

login_check:
    pattern:  /logged
admin_check:
    pattern:  /adminlogged
    defaults: { _controller: LandingPageBundle:Landing:adminLogin } # line added

      



There is no controller for the route login_check

as it is managed by Symfony2:

You won't need to inject a controller for the / login_check URL as the firewall will automatically catch and process any form submitted to that URL. However, for this url you must have a route (as shown here) and also one for your logout path (see Logout).

Source: Official Symfony2 Documentation .

+1


source







All Articles