diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index a762270..0e9c9dc 100755 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -25,6 +25,7 @@ use App\Http\Controllers\Controller; use App\User; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; class LoginController extends Controller { @@ -77,4 +78,17 @@ class LoginController extends Controller return $this->originalAttemptLogin($request); } + + public function authenticated(Request $request, User $user) + { + if ($user->originalIP !== $request->ip()) + { + Log::alert('User IP address changed from last login. Updating.', [ + 'prev' => $user->originalIP, + 'new' => $request->ip() + ]); + $user->originalIP = $request->ip(); + $user->save(); + } + } } diff --git a/app/Http/Middleware/IPHistoryMiddleware.php b/app/Http/Middleware/IPHistoryMiddleware.php new file mode 100644 index 0000000..eecadbf --- /dev/null +++ b/app/Http/Middleware/IPHistoryMiddleware.php @@ -0,0 +1,21 @@ +