Skip to content

Commit

Permalink
Fix be745ef - Fixes #396
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed Oct 12, 2024
1 parent c45fb2f commit 70cd730
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion app/Listeners/Authentication/FailedLoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function handle(mixed $event) : void
* @var \App\Models\User
*/
$user = $event->user;
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$ip = config('2fauth.proxy_headers.forIp')
? $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip())
: $this->request->ip();

$log = $user->authentications()->create([
'ip_address' => $ip,
Expand Down
6 changes: 4 additions & 2 deletions app/Listeners/Authentication/LoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public function handle(mixed $event) : void
/**
* @var \App\Models\User
*/
$user = $event->user;
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp')
? $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip())
: $this->request->ip();
$userAgent = $this->request->userAgent();
$known = $user->authentications()
->whereIpAddress($ip)
Expand Down
6 changes: 4 additions & 2 deletions app/Listeners/Authentication/LogoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public function handle(mixed $event) : void
/**
* @var \App\Models\User
*/
$user = $event->user;
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp')
? $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip())
: $this->request->ip();
$userAgent = $this->request->userAgent();
$log = $user->authentications()
->whereIpAddress($ip)
Expand Down
6 changes: 4 additions & 2 deletions app/Listeners/Authentication/OtherDeviceLogoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ public function handle(mixed $event) : void
/**
* @var \App\Models\User
*/
$user = $event->user;
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp')
? $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip())
: $this->request->ip();
$userAgent = $this->request->userAgent();
$authLog = $user->authentications()
->whereIpAddress($ip)
Expand Down
6 changes: 4 additions & 2 deletions app/Listeners/Authentication/VisitedByProxyUserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public function handle(mixed $event) : void
/**
* @var \App\Models\User
*/
$user = $event->user;
$ip = $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip());
$user = $event->user;
$ip = config('2fauth.proxy_headers.forIp')
? $this->request->header(config('2fauth.proxy_headers.forIp'), $this->request->ip())
: $this->request->ip();
$userAgent = $this->request->userAgent();
$guard = config('auth.defaults.guard');
$known = $user->authentications()
Expand Down

0 comments on commit 70cd730

Please sign in to comment.