WIP: Road to 1.0.0 #1
|
@ -25,6 +25,7 @@ use App\Http\Controllers\Controller;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -77,4 +78,17 @@ class LoginController extends Controller
|
||||||
|
|
||||||
return $this->originalAttemptLogin($request);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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