Support the ongoing development of Laravel.io →
Authentication Session
Last updated 2 years 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-to-routes)

Last updated 7 years ago.
0

Thanks! I solved this.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.