diff --git a/app/config/errors.php b/app/config/errors.php index ac5bc34ee..3510f781e 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -18,16 +18,6 @@ return [ 'description' => 'The requested service is disabled. You can enable/disable a service from the Appwrite console or by contacting the project owner.', 'code' => 503, ], - Exception::INVALID_READ_PERMISSIONS => [ - 'name' => Exception::INVALID_READ_PERMISSIONS, - 'description' => 'Invalid format for read permissions. Please check the documentation.', - 'code' => 400, - ], - Exception::INVALID_WRITE_PERMISSIONS => [ - 'name' => Exception::INVALID_WRITE_PERMISSIONS, - 'description' => 'Invalid format for write permissions. Please check the documentation.', - 'code' => 400, - ], Exception::GENERAL_UNAUTHORIZED_SCOPE => [ 'name' => Exception::GENERAL_UNAUTHORIZED_SCOPE, 'description' => 'The current user or API key does not have the required scopes to access the requested resource.', diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 0375e9a1c..9df02ddaf 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -1628,12 +1628,12 @@ App::post('/v1/database/collections/:collectionId/documents') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($data['$read'] as $read) { if (!Authorization::isRole($read)) { - throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_READ_PERMISSIONS); + throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } foreach ($data['$write'] as $write) { if (!Authorization::isRole($write)) { - throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_WRITE_PERMISSIONS); + throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } } @@ -2013,12 +2013,12 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($data['$read'] as $read) { if (!Authorization::isRole($read)) { - throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_READ_PERMISSIONS); + throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } foreach ($data['$write'] as $write) { if (!Authorization::isRole($write)) { - throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_WRITE_PERMISSIONS); + throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } } diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 0726fb871..6413fdc69 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -68,12 +68,12 @@ App::post('/v1/storage/files') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($read as $role) { if (!Authorization::isRole($role)) { - throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_READ_PERMISSIONS); + throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } foreach ($write as $role) { if (!Authorization::isRole($role)) { - throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_WRITE_PERMISSIONS); + throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } } @@ -602,12 +602,12 @@ App::put('/v1/storage/files/:fileId') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($read as $role) { if (!Authorization::isRole($role)) { - throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_READ_PERMISSIONS); + throw new Exception('Read permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } foreach ($write as $role) { if (!Authorization::isRole($role)) { - throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::INVALID_WRITE_PERMISSIONS); + throw new Exception('Write permissions must be one of: ('.\implode(', ', $roles).')', 400, Exception::USER_UNAUTHORIZED); } } } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 14177d95d..83d6d199a 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -92,10 +92,10 @@ class Exception extends \Exception const COLLECTION_LIMIT_EXCEEDED = 'collection_limit_exceeded'; /** Documents */ - const DOCUMENT_NOT_FOUND = 'document_not_found'; - const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure'; - const DOCUMENT_MISSING_PAYLOAD = 'document_missing_payload'; - const DOCUMENT_ALREADY_EXISTS = 'document_already_exists'; + const DOCUMENT_NOT_FOUND = 'document_not_found'; + const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure'; + const DOCUMENT_MISSING_PAYLOAD = 'document_missing_payload'; + const DOCUMENT_ALREADY_EXISTS = 'document_already_exists'; /** Attribute */ const ATTRIBUTE_NOT_FOUND = 'attribute_not_found'; @@ -140,8 +140,6 @@ class Exception extends \Exception const GENERAL_ACCESS_FORBIDDEN = 'general_access_forbidden'; const GENERAL_UNKNOWN_ORIGIN = 'general_unknown_origin'; const GENERAL_SERVICE_DISABLED = 'general_service_disabled'; - const INVALID_READ_PERMISSIONS = 'invalid_read_permissions'; - const INVALID_WRITE_PERMISSIONS = 'invalid_write_permissions'; const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope'; const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded'; const GENERAL_SMTP_DISABLED = 'general_smtp_disabled';