From 23d0aae23bf4db178d017f1b7fe50f17ede9a605 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 27 Dec 2023 00:03:16 +0000 Subject: [PATCH] improve get file token --- app/controllers/api/storage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 21c4b40116..f8388a682b 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1680,7 +1680,13 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/tokens/:tokenId') throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } - $response->dynamic($file, Response::MODEL_FILE_TOKEN); + $token = $dbForProject->getDocument('fileTokens', $tokenId); + + if($token->isEmpty() || $token->getAttribute('bucketInternalId') != $bucket->getInternalId() || $token->getAttribute('fileInternalId') != $file->getInternalId()) { + throw new Exception(Exception::STORAGE_FILE_TOKEN_NOT_FOUND); + } + + $response->dynamic($token, Response::MODEL_FILE_TOKEN); }); App::put('/v1/storage/buckets/:bucketId/files/:fileId/tokens/:tokenId')