How to force user logout symfony2

I want to force a user to logout in symfony2 after checking that it has not enough capabilities for access into a specific secured area.

I’ve tried with :

Read More
$this->get('request')->getSession()->invalidate();

but it seems that something goes wrong, the user still logged in until I logged him out using /logout route.

I’ve to mention that I’m using KayueWordpressBundle to connect my symfony app with a wordpress based website to create a custom back office.

Here is my security.yml file

security:
firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false
    login_firewall:
        pattern:    ^/$
        anonymous:  ~
    secured_area:
        pattern:    ^/
        kayue_wordpress: ~
        form_login:
            check_path: /login_check
            login_path: /
        logout:
            path:   /logout
            target: /
access_control:
    - { path: ^/admin, roles: ROLE_ADMIN }

providers:
    wordpress:
        entity: { class: KayueWordpressBundleEntityUser, property: username }

encoders:
    KayueWordpressBundleEntityUser:
        id: kayue_wordpress.security.encoder.phpass

How can I do this please ?

Thank you

Related posts

Leave a Reply

1 comment