Use a proper DELETE to delete the form in a more resty way

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-08-30 21:32:47 +02:00
commit fa8be2e60d
No known key found for this signature in database
GPG key ID: F941078878347C0C
3 changed files with 10 additions and 6 deletions

View file

@ -397,8 +397,12 @@ class ApiController extends Controller {
* @param int $formId
* @return DataResponse
*/
public function removeForm($id) {
$formToDelete = $this->eventMapper->find($id);
public function removeForm(int $id) {
try {
$formToDelete = $this->eventMapper->find($id);
} catch (DoesNotExistException $e) {
return new Http\JSONResponse([], Http::STATUS_NOT_FOUND);
}
if ($this->userId !== $formToDelete->getOwner() && !$this->groupManager->isAdmin($this->userId)) {
return new DataResponse(null, Http::STATUS_UNAUTHORIZED);
}