diff --git a/app/controllers/general.php b/app/controllers/general.php index 434117846b..a25e4826b9 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -367,6 +367,16 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo return false; } +App::init() + ->groups(['api']) + ->inject('project') + ->inject('mode') + ->action(function (Document $project, string $mode) { + if ($mode === APP_MODE_ADMIN && $project->getId() === 'console') { + throw new AppwriteException(AppwriteException::GENERAL_BAD_REQUEST, 'Admin mode is not allowed for console project'); + } + }); + App::init() ->groups(['api', 'web']) ->inject('utopia') diff --git a/tests/e2e/General/ModeTest.php b/tests/e2e/General/ModeTest.php new file mode 100644 index 0000000000..ceafbc4b3a --- /dev/null +++ b/tests/e2e/General/ModeTest.php @@ -0,0 +1,30 @@ +client->call(Client::METHOD_GET, '/account', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-mode' => 'admin', + ], $this->getHeaders())); + + $this->assertEquals(400, $response['headers']['status-code']); + $this->assertEquals(Exception::GENERAL_BAD_REQUEST, $response['body']['type']); + } +}