Search code examples
symfonysymfony-sonata

Login wih the same login_check Sonata User bundle and Sonata admin bundle


I got a app who has Sonata User bundle and Sonata Admin bundle, but when I login with Sonata User bundle, and after I try to go to the admin page, I have to do login again,

Some Know how to ingrate both, to just has one login

Thanks any advice!!


Solution

  • Well I found the solution, I put the same check_path and login_path in the admin firewall that take by default in the main firewall, Here I share the code in the security.yml:

    # -> custom firewall for the admin area of the URL

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

    # -> end custom configuration

    # defaut login area for standard users

       main:
            pattern:      .*
            fr3d_ldap:        ~
            form_login:
                always_use_default_target_path: true
                default_target_path: /
    

    I hope this help to someone!!