phpsymfonysecurityroles

Symfony User Logout After Role Change


When changing user roles (in database or via code) user is getting logged out automatically. Is there a way to prevent this behaviour?

Using Symfony 5.1.2


Solution

  • Reload the user programatically using TokenStorageInterface, create new UsernamePasswordToken (or whichever you are using) and replace the current one with $tokenStorage->setToken($newToken);.