Track IP changes
This commit is contained in:
parent
5cf6b2b241
commit
3b28bf1cfe
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
app/Http/Middleware/IPHistoryMiddleware.php
Normal file
21
app/Http/Middleware/IPHistoryMiddleware.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IPHistoryMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user