I`am using symfony2. When I change some user role I would like that the roles would be change immediately even when that user is currently logged.
I have found something like this:
$this->get('security.context')->getToken();
$token->setAuthenticated(false);
But this is done within the current user. I would like to do this for another user.
I am not changing the roles for user which I am logged in. I am changing it for another user, who is possibly logged in.
Any help would be appreciated.
P.S. Storing session in database is not acceptable for my problem.
You could create a table with a commands for example to log out a specific user, and then create a listener so when the user is refreshed from database (eg. when he creates another request) then this commands are taken into place and the code logs out the user.
You cannot really control somebody else session.
About specific roles, it should be fine to just update the user roles in DB because the user is refreshed with every request.