From 0a5b4fe7e2c9aafadfe540c96a8648c9d9e979f1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 May 2021 23:45:56 +1000 Subject: [PATCH 1/2] Wrap IP in json --- app/Listeners/User/UpdateUserLastLogin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Listeners/User/UpdateUserLastLogin.php b/app/Listeners/User/UpdateUserLastLogin.php index 266113b269..fa087be5e4 100644 --- a/app/Listeners/User/UpdateUserLastLogin.php +++ b/app/Listeners/User/UpdateUserLastLogin.php @@ -67,8 +67,10 @@ class UpdateUserLastLogin implements ShouldQueue $user->save(); } + $arr = json_encode(['ip' => $ip]); + SystemLogger::dispatch( - $ip, + $arr, SystemLog::CATEGORY_SECURITY, SystemLog::EVENT_USER, SystemLog::TYPE_LOGIN_SUCCESS, From 1cc3eed32262ec7349a0b2164d7db55d525e8359 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 19 May 2021 08:08:37 +1000 Subject: [PATCH 2/2] Fixes for exceptions --- app/Exceptions/Handler.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index f95c0d3cbf..8a59ad95f1 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -14,6 +14,7 @@ namespace App\Exceptions; use App\Exceptions\FilePermissionsFailure; use App\Exceptions\InternalPDFFailure; use App\Exceptions\PhantomPDFFailure; +use App\Utils\Ninja; use Exception; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; @@ -75,7 +76,26 @@ class Handler extends ExceptionHandler return; } - if (app()->bound('sentry') && $this->shouldReport($exception)) { + if(Ninja::isHosted()){ + + app('sentry')->configureScope(function (Scope $scope): void { + + if(auth()->guard('contact') && auth()->guard('contact')->user()) + $key = auth()->guard('contact')->user()->company->account->key; + elseif (auth()->guard('user') && auth()->guard('user')->user()) + $key = auth()->user()->account->key; + else + $key = 'Anonymous'; + + $scope->setUser([ + 'id' => 'Hosted_User', + 'email' => 'hosted@invoiceninja.com', + 'name' => $key, + ]); + }); + + } + elseif (app()->bound('sentry') && $this->shouldReport($exception)) { app('sentry')->configureScope(function (Scope $scope): void { if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) { $scope->setUser([