Support the ongoing development of Laravel.io →
Authentication Session
Last updated 1 month ago.
0

I would store the user's IP to the DB when he logs-in. Then I would create new middleware, something like "logoutOnIPChange" and register this middleware to Kernel "$middleware" property.

The middleware handle method can look like this

if (Auth::user()->ip != Request::ip())
{
Auth::logout()
}

PS: remember to use Auth and Request facades in the logoutOnIPChange middleware file.

PS2: maybe registering it to kernel is not good idea. You should create a route middleware and assign this middleware to your desired routes (see https://laravel.com/docs/5.4/middleware#assigning-middleware-t...)

Last updated 5 years ago.
0

Thanks! I solved this.

0

Sign in to participate in this thread!

LaraJobs

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.