Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

How to log out the user if the IP has changed?

$
0
0

I want to log out the user if the IP has changed.

I managed to make it by creating a field lastLoginIp in the Users table, setting it in the onAuthenticationSuccess, and then checking in the User::isEqualTo() method:

if($user->getLastLoginIp() !== Utils::getIp()) {    return false;}

The problem is that it broke impersonation, because of course the IP of the admin is different than the IP of the user.

How can this be implemented? (and the user must not get logged out if somebody impersonates him)


Viewing all articles
Browse latest Browse all 3925

Trending Articles