1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

feat: remove unused error

This commit is contained in:
Christy Jacob 2022-02-07 01:33:48 +04:00
parent 30c5d3c264
commit 42e424b70a
4 changed files with 12 additions and 24 deletions

View file

@ -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.',

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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';