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:
parent
2e3be4d460
commit
fa8be2e60d
3 changed files with 10 additions and 6 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue