mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Report uploads
This commit is contained in:
@@ -130,7 +130,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
$this->auditLogAttachments($files);
|
||||
$this->auditLogAttachmentInfo($files);
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
@@ -149,23 +149,5 @@ class EditController extends Controller
|
||||
return $redirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function auditLogAttachments(?array $files): void
|
||||
{
|
||||
if (null === $files) {
|
||||
Log::channel('audit')->info('No files found');
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* @var int $index
|
||||
* @var UploadedFile $file
|
||||
*/
|
||||
foreach ($files as $index => $file) {
|
||||
Log::channel('audit')->info(sprintf('File [%d/%d] upload attachment "%s", content is: "%s".', $index + 1, count($files), $file->getClientOriginalName(), $file->getContent()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,7 +28,9 @@ use FireflyIII\Support\Http\Controllers\UserNavigation;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class Controller.
|
||||
@@ -119,4 +121,24 @@ abstract class Controller extends BaseController
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function auditLogAttachmentInfo(?array $files): void
|
||||
{
|
||||
if (null === $files) {
|
||||
Log::channel('audit')->info('No files found');
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* @var int $index
|
||||
* @var UploadedFile $file
|
||||
*/
|
||||
foreach ($files as $index => $file) {
|
||||
Log::channel('audit')->info(sprintf('File [%d/%d] upload attachment "%s", content is: "%s".', $index + 1, count($files), $file->getClientOriginalName(), $file->getContent()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -306,6 +306,7 @@ class TagController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
$this->auditLogAttachmentInfo($files);
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
@@ -341,6 +342,7 @@ class TagController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
$this->auditLogAttachmentInfo($files);
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user