mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
allow sending edit key as header
This commit is contained in:
parent
9595b7f6f5
commit
1593435254
2 changed files with 9 additions and 1 deletions
|
|
@ -34,6 +34,14 @@ class BaseController {
|
||||||
return $this->request->data[$name] ?? $default;
|
return $this->request->data[$name] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getEditKey(): string {
|
||||||
|
$key = Request::getHeader('EDIT_KEY');
|
||||||
|
if ($key) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
return $this->post('key', '');
|
||||||
|
}
|
||||||
|
|
||||||
protected function json(
|
protected function json(
|
||||||
mixed $data,
|
mixed $data,
|
||||||
int $code = 200,
|
int $code = 200,
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class DemoController extends BaseController {
|
||||||
$backend = $this->post('backend', '');
|
$backend = $this->post('backend', '');
|
||||||
$path = $this->post('path', '');
|
$path = $this->post('path', '');
|
||||||
$url = $this->post('url', '');
|
$url = $this->post('url', '');
|
||||||
$editKey = $this->post('key', '');
|
$editKey = $this->getEditKey();
|
||||||
if ($editKey !== $this->editKey || '' === $editKey) {
|
if ($editKey !== $this->editKey || '' === $editKey) {
|
||||||
throw new InvalidKeyException('Invalid key');
|
throw new InvalidKeyException('Invalid key');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue