1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

allow access key to access private demos

This commit is contained in:
Robin Appelman 2025-05-03 15:45:22 +02:00
commit 52b9bc09fd
10 changed files with 37 additions and 52 deletions

View file

@ -34,8 +34,12 @@ class BaseController {
return $this->request->data[$name] ?? $default;
}
protected function getAccessKey(): string {
return Request::getHeader('ACCESS-KEY');
}
protected function getEditKey(): string {
$key = Request::getHeader('EDIT_KEY');
$key = Request::getHeader('EDIT-KEY');
if ($key) {
return $key;
}

View file

@ -28,7 +28,8 @@ class DemoController extends BaseController {
ChatProvider $chatProvider,
DemoListProvider $demoListProvider,
DemoStore $store,
string $editKey
string $editKey,
string $accessKey,
) {
parent::__construct($request, $response);
$this->demoProvider = $demoProvider;
@ -36,6 +37,11 @@ class DemoController extends BaseController {
$this->demoListProvider = $demoListProvider;
$this->store = $store;
$this->editKey = $editKey;
if ($this->getAccessKey() === $accessKey) {
$this->demoProvider->showPrivateData(true);
$this->demoListProvider->showPrivateData(true);
}
}
public function get(string $id): void {