diff --git a/app/init.php b/app/init.php index 3744bb055c..f47176caae 100644 --- a/app/init.php +++ b/app/init.php @@ -1334,6 +1334,10 @@ App::setResource('project', function ($dbForConsole, $request, $console) { $project = Authorization::skip(fn () => $dbForConsole->getDocument('projects', $projectId)); + if($project->getAttribute('region') !== System::getEnv('_APP_REGION')){ + throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Project is not accessible in this region. Please make sure you are using the correct endpoint'); + } + return $project; }, ['dbForConsole', 'request', 'console']); @@ -1397,10 +1401,11 @@ App::setResource('console', function () { 'githubSecret' => System::getEnv('_APP_CONSOLE_GITHUB_SECRET', ''), 'githubAppid' => System::getEnv('_APP_CONSOLE_GITHUB_APP_ID', '') ], + 'region' => System::getEnv('_APP_REGION', 'default') ]); }, []); -App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, Cache $cache, Document $project) { +App::setResource('dbForPltroject', function (Group $pools, Database $dbForConsole, Cache $cache, Document $project) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForConsole; }