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:
parent
1593435254
commit
52b9bc09fd
10 changed files with 37 additions and 52 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue