diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 541a0b42d3..95927b380a 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -954,7 +954,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } - $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') == $bucket->getInternalId(); + $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getInternalId(); $fileSecurity = $bucket->getAttribute('fileSecurity', false); $validator = new Authorization(Database::PERMISSION_READ); $valid = $validator->isValid($bucket->getRead()); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 5dd9966cb2..0f4ef70a0b 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -542,7 +542,7 @@ App::init() $bucketId = $parts[1] ?? null; $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') == $bucket->getInternalId(); + $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getInternalId(); $isAPIKey = Auth::isAppUser(Authorization::getRoles()); $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); diff --git a/app/init/resources.php b/app/init/resources.php index 1be8d4f9f6..a5949bc9e5 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -861,7 +861,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { $token = Authorization::skip(fn () => $dbForProject->getDocument('resourceTokens', $tokenId)); - if ($token->isEmpty() || $token->getAttribute('secret') != $secret) { + if ($token->isEmpty() || $token->getAttribute('secret') !== $secret) { return new Document([]); } @@ -869,7 +869,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { $internalIds = explode(':', $token->getAttribute('resourceInternalId')); $ids = explode(':', $token->getAttribute('resourceId')); - if (count($internalIds) != 2 || count($ids) != 2) { + if (count($internalIds) !== 2 || count($ids) !== 2) { return new Document([]); } diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php index ef12ece80d..76e161e101 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php @@ -82,12 +82,13 @@ class Create extends Action $fileSecurity = $bucket->getAttribute('fileSecurity', false); $validator = new Authorization(Database::PERMISSION_UPDATE); $bucketPermission = $validator->isValid($bucket->getUpdate()); - if (!$fileSecurity && !$bucketPermission) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } - $filePermission = $validator->isValid($file->getUpdate()); - if ($fileSecurity && !$bucketPermission && !$filePermission) { + if ($fileSecurity) { + $filePermission = $validator->isValid($file->getUpdate()); + if (!$bucketPermission && !$filePermission) { + throw new Exception(Exception::USER_UNAUTHORIZED); + } + } elseif (!$bucketPermission) { throw new Exception(Exception::USER_UNAUTHORIZED); } diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/JWT/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/JWT/Get.php index e539cb1b9a..f209908878 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/JWT/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/JWT/Get.php @@ -66,7 +66,7 @@ class Get extends Action // calculate maxAge based on expiry date $maxAge = PHP_INT_MAX; $expire = $token->getAttribute('expire'); - if ($expire != null) { + if ($expire !== null) { $now = new \DateTime(); $expiryDate = new \DateTime($expire); if ($expiryDate < $now) { diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index e60d342b0b..157ccc8263 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -177,7 +177,7 @@ class OpenAPI3 extends Format $namespace = $sdk->getNamespace() ?? 'default'; - $desc = $desc ?? ''; + $desc ??= ''; $descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc; $temp = [ diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index fae164f0a6..b6536df9df 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -173,7 +173,7 @@ class Swagger2 extends Format $namespace = $sdk->getNamespace() ?? 'default'; - $desc = $desc ?? ''; + $desc ??= ''; $descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc; $temp = [