mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Disable attachment API for demo users
This commit is contained in:
parent
d777a1f2b8
commit
2e5bc750d1
12
.ci/php-cs-fixer/composer.lock
generated
12
.ci/php-cs-fixer/composer.lock
generated
@ -226,16 +226,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.43.1",
|
||||
"version": "v3.45.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "91c0b47216aa43b09656b4d99aa9dade2f3ad8fc"
|
||||
"reference": "c0daa33cb2533cd73f48dde1c70c2afa3e7953b5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/91c0b47216aa43b09656b4d99aa9dade2f3ad8fc",
|
||||
"reference": "91c0b47216aa43b09656b4d99aa9dade2f3ad8fc",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c0daa33cb2533cd73f48dde1c70c2afa3e7953b5",
|
||||
"reference": "c0daa33cb2533cd73f48dde1c70c2afa3e7953b5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -304,7 +304,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.43.1"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.45.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -312,7 +312,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-29T09:42:16+00:00"
|
||||
"time": "2023-12-30T02:07:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
|
@ -29,6 +29,8 @@ use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class DestroyController
|
||||
@ -64,6 +66,12 @@ class DestroyController extends Controller
|
||||
*/
|
||||
public function destroy(Attachment $attachment): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$this->repository->destroy($attachment);
|
||||
app('preferences')->mark();
|
||||
|
||||
|
@ -33,9 +33,11 @@ use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response as LaravelResponse;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class ShowController
|
||||
@ -73,6 +75,11 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function download(Attachment $attachment): LaravelResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
if (false === $attachment->uploaded) {
|
||||
throw new FireflyException('200000: File has not been uploaded (yet).');
|
||||
}
|
||||
@ -116,6 +123,12 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$manager = $this->getManager();
|
||||
|
||||
// types to get, page size:
|
||||
@ -148,6 +161,11 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function show(Attachment $attachment): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var AttachmentTransformer $transformer */
|
||||
|
@ -34,7 +34,9 @@ use FireflyIII\Transformers\AttachmentTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\Fractal\Resource\Item;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
@ -72,6 +74,11 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$data = $request->getAll();
|
||||
$attachment = $this->repository->store($data);
|
||||
@ -91,6 +98,12 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function upload(Request $request, Attachment $attachment): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/** @var AttachmentHelperInterface $helper */
|
||||
$helper = app(AttachmentHelperInterface::class);
|
||||
$body = $request->getContent();
|
||||
|
@ -31,7 +31,9 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Transformers\AttachmentTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\Fractal\Resource\Item;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class UpdateController
|
||||
@ -67,6 +69,11 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Attachment $attachment): JsonResponse
|
||||
{
|
||||
if(true === auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->info(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$data = $request->getAll();
|
||||
$this->repository->update($attachment, $data);
|
||||
$manager = $this->getManager();
|
||||
|
@ -160,13 +160,14 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
// may have multiple tags:
|
||||
foreach ($journal['tags'] as $tag) {
|
||||
if(!in_array($tagId, $tagIds, true)) {
|
||||
continue;
|
||||
}
|
||||
$tagId = (int)$tag['id'];
|
||||
$tagName = (string)$tag['name'];
|
||||
$journalId = (int)$journal['transaction_journal_id'];
|
||||
|
||||
if(!in_array($tagId, $tagIds, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($journalId, $listedJournals, true)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ use FireflyIII\Models\WebhookAttempt;
|
||||
use FireflyIII\Models\WebhookMessage;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
/**
|
||||
@ -45,7 +46,7 @@ class StandardWebhookSender implements WebhookSenderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws GuzzleException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Transformers\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
@ -49,7 +50,7 @@ class BillTransformer extends AbstractTransformer
|
||||
private array $paidDates;
|
||||
|
||||
/**
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user