1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5741 from turbo124/v5-develop

Fixes for Exception Handler
This commit is contained in:
David Bomba 2021-05-19 08:09:03 +10:00 committed by GitHub
commit 8b397cc15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -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([

View File

@ -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,