In my Symfony project I'm using UserInterface in my User entity to handle authentication. I also use EquatableInterface to check if user's email is changed while he's logged in.
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof Account) {
return false;
}
if ($this->email !== $user->getEmail()) {
return false;
}
return true;
}
All works as expected, but when I change user's email in DB I'm not logged out, just not authenticated as you can see in the following screenshot.
So I would know how can I check in a controller if user is authenticated? And how can I force user to log out when isEqualTo returns false?
