I have a User
entity, which has a boolean column isActivated
. Depending on the value of the column for each user, he may or may not be able to login (i.e. he hasn't activated his account so no login). I've achieved that by assigning an simple_form.authenticator
in the firewall which check upon every login.
I'm trying to figure out how force logout a user while he's still loged in.
Consider the following scenario:
- The user logs in while his account is still active.
- An administrator deactivates the user's account.
- The user is logged out due to the fact it's not active anymore.
Unfortunately step #3 doesn't happen. The reason may lay in the fact that the user has already received the token and is considered to be "tursted" by the Symfony 2.5
's firewall (probably the token is cached in the security context?).
I'm wondering what would be the best way to overcome this issue? Should I write a kernel event listener or perhaps a Custom User Provider?
$this->get('security.token_storage')->setToken(null); $this->get('session')->invalidate();
– Mote