简体   繁体   中英

Symfony SecurityBundle: how to stay on the same page after logout?

The logout process is handled by logout section in security.yml

            logout:
                path: /logout
                target: /

where target option defines where the user shoud be redirected to after logout.

The question is: Is possible to customize this behaviour (like in form_login section where setting use_referer: true allowes to be redirected to the referer page) ?

What I need: I need to stay on the same page where "logout" has been clicked since, of course, it does not require to be authenticated with a role.

I didn't find any solution without re-implementing whole logout process.

It is possible to configure custom logout handler. In that handler you can override the default Symfony behaviour.

secured_area: 
        #.....
        logout:
            path:   /logout
            success_handler: some.service.id
        #......

This answer can give you a good idea on how to implement it Symfony logout handler

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM