adding app region to console project

This commit is contained in:
shimon 2024-11-10 12:26:34 +02:00
parent b5efbdbb0f
commit a0280e3c43

View file

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