diff --git a/app/config/errors.php b/app/config/errors.php index a6cf0c4af..97ac6d1a4 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -28,6 +28,11 @@ return [ 'description' => 'The request originated from an unknown origin. If you trust this domain, please list it as a trusted platform in the Appwrite console.', 'code' => 403, ], + Exception::GENERAL_PROJECT_PAUSED => [ + 'name' => Exception::GENERAL_PROJECT_PAUSED, + 'description' => 'The requested project is paused. You can resume the project from the Appwrite console.', + 'code' => 503, + ], Exception::GENERAL_SERVICE_DISABLED => [ 'name' => Exception::GENERAL_SERVICE_DISABLED, 'description' => 'The requested service is disabled. You can enable the service from the Appwrite console.', diff --git a/app/controllers/general.php b/app/controllers/general.php index c1b8457d1..0fdfe28d0 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -346,6 +346,11 @@ App::init() Authorization::setRole($authRole); } + $paused = $project->getAttribute('paused', false); + if ($paused && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles()))) { + throw new AppwriteException(AppwriteException::GENERAL_PROJECT_PAUSED); + } + $service = $route->getLabel('sdk.namespace', ''); if (!empty($service)) { if ( diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index c0c4ad092..6a5e26df7 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -39,6 +39,7 @@ class Exception extends \Exception public const GENERAL_MOCK = 'general_mock'; public const GENERAL_ACCESS_FORBIDDEN = 'general_access_forbidden'; public const GENERAL_UNKNOWN_ORIGIN = 'general_unknown_origin'; + public const GENERAL_PROJECT_PAUSED = 'general_project_paused'; public const GENERAL_SERVICE_DISABLED = 'general_service_disabled'; public const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope'; public const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';