3

can someone tell me what are the steps i have to do so that i can logout from my backoffice i'm using symfony2 and fosuser bundle here's my security.yml

security:
encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            default_target_path: /admin
            # if you are using Symfony < 2.8, use the following config instead:
            # csrf_provider: form.csrf_provider

        logout:       true
        anonymous:    true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

i've tried to add

logout:
        path:   /logout
        target: /login

and

logout:
            path:   /logout
            target: /
        anonymous:    true

but not working what to do ?

samayo
  • 16,163
  • 12
  • 91
  • 106

2 Answers2

4

Logout function is inbuilt within the FOSUserBundle.

You can check this buy running

php app/console route:debug | grep logout

and it should display

Name                              Method   Scheme Host Path 
fos_user_security_logout          GET      ANY    ANY  /logout 

If you wish to override the FOSUserBundle's routes this answer is very helpful: https://stackoverflow.com/a/19608870/5760411

Or the documentation: http://symfony.com/doc/current/bundles/FOSUserBundle/overriding_controllers.html

Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124
Brendan
  • 908
  • 2
  • 15
  • 30
1

You forgot to add route definition.

In routing.yml:

logout:
    path: /logout
Arthur
  • 2,869
  • 14
  • 25