diff --git a/app/Listeners/Authentication/FailedLoginListener.php b/app/Listeners/Authentication/FailedLoginListener.php index d77a01fc..45c6a591 100644 --- a/app/Listeners/Authentication/FailedLoginListener.php +++ b/app/Listeners/Authentication/FailedLoginListener.php @@ -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, diff --git a/app/Listeners/Authentication/LoginListener.php b/app/Listeners/Authentication/LoginListener.php index fde59925..c8a56717 100644 --- a/app/Listeners/Authentication/LoginListener.php +++ b/app/Listeners/Authentication/LoginListener.php @@ -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) diff --git a/app/Listeners/Authentication/LogoutListener.php b/app/Listeners/Authentication/LogoutListener.php index 5f30b7f2..14fd5c4e 100644 --- a/app/Listeners/Authentication/LogoutListener.php +++ b/app/Listeners/Authentication/LogoutListener.php @@ -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) diff --git a/app/Listeners/Authentication/OtherDeviceLogoutListener.php b/app/Listeners/Authentication/OtherDeviceLogoutListener.php index 1309d526..386cc2e4 100644 --- a/app/Listeners/Authentication/OtherDeviceLogoutListener.php +++ b/app/Listeners/Authentication/OtherDeviceLogoutListener.php @@ -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) diff --git a/app/Listeners/Authentication/VisitedByProxyUserListener.php b/app/Listeners/Authentication/VisitedByProxyUserListener.php index a0f80073..7e617224 100644 --- a/app/Listeners/Authentication/VisitedByProxyUserListener.php +++ b/app/Listeners/Authentication/VisitedByProxyUserListener.php @@ -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()