Fix ip forwarded by proxy not being logged correctly - Closes #396

This commit is contained in:
Bubka 2024-10-12 18:19:29 +02:00
parent bc96815deb
commit be745efc26
5 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp') ?? $this->request->ip();
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$log = $user->authentications()->create([
'ip_address' => $ip,

View File

@ -44,7 +44,7 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp') ?? $this->request->ip();
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$userAgent = $this->request->userAgent();
$known = $user->authentications()
->whereIpAddress($ip)

View File

@ -43,7 +43,7 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp') ?? $this->request->ip();
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$userAgent = $this->request->userAgent();
$log = $user->authentications()
->whereIpAddress($ip)

View File

@ -49,7 +49,7 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp') ?? $this->request->ip();
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$userAgent = $this->request->userAgent();
$authLog = $user->authentications()
->whereIpAddress($ip)

View File

@ -24,7 +24,7 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp') ?? $this->request->ip();
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$userAgent = $this->request->userAgent();
$guard = config('auth.defaults.guard');
$known = $user->authentications()