I have a basic form-login authentication in my app, and I set up a handler using AuthenticationHandlerInterface, in which I'm setting session vars in the onAuthenticationSuccess() method.
The problem is that when I switch to another user (using ROLE_ALLOWED_TO_SWITCH), my handler is not called anymore, and the session vars I set before remain those of the user before switching.
Example :
- Logging with user X
- Setting session var myVar to X->someAttribute (inside the authentication handler)
- Switching to user Y
- Handler not called : myVar keeps keeps the same value
(I know that myVar = X->someAttribute is not a good example since I can already access it from the security token object, but it was to simplify the problem)
Thanks
EDIT : extract of security.yml
firewalls:
main:
pattern: ^/
anonymous: ~
switch_user: { role: ROLE_ADMIN, parameter: _switch }
form_login:
provider: sso
success_handler: authentication_handler
login_path: /login
check_path: /login_check
logout:
path: /logout
target: /home