mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
better error codes for set url
This commit is contained in:
parent
f4f1454d59
commit
ceea727d12
1 changed files with 5 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ use Demostf\API\Demo\DemoStore;
|
||||||
use Demostf\API\Providers\ChatProvider;
|
use Demostf\API\Providers\ChatProvider;
|
||||||
use Demostf\API\Providers\DemoListProvider;
|
use Demostf\API\Providers\DemoListProvider;
|
||||||
use Demostf\API\Providers\DemoProvider;
|
use Demostf\API\Providers\DemoProvider;
|
||||||
|
use Flight;
|
||||||
use flight\net\Request;
|
use flight\net\Request;
|
||||||
use flight\net\Response;
|
use flight\net\Response;
|
||||||
use function intval;
|
use function intval;
|
||||||
|
|
@ -126,7 +127,8 @@ class DemoController extends BaseController {
|
||||||
$url = (string) $this->post('url', '');
|
$url = (string) $this->post('url', '');
|
||||||
$editKey = (string) $this->post('key', '');
|
$editKey = (string) $this->post('key', '');
|
||||||
if ($editKey !== $this->editKey || '' === $editKey) {
|
if ($editKey !== $this->editKey || '' === $editKey) {
|
||||||
throw new InvalidArgumentException('Invalid key');
|
Flight::response()->status(401)->write('Invalid key')->send();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$demo = $this->demoProvider->get((int) $id);
|
$demo = $this->demoProvider->get((int) $id);
|
||||||
|
|
@ -138,7 +140,8 @@ class DemoController extends BaseController {
|
||||||
$this->store->remove($demo);
|
$this->store->remove($demo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException('Invalid demo hash');
|
Flight::response()->status(412)->write('Invalid demo hash')->send();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue