Skip to content

Commit

Permalink
Fix bad error status
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi committed Nov 26, 2022
1 parent e05ee0a commit 861d97b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down Expand Up @@ -273,6 +274,10 @@ public function userToggleDelegation(ManagerRegistry $doctrine, string $username
*/
public function userDelegateAdd(ManagerRegistry $doctrine, Request $request, string $username)
{
if (!is_numeric($request->get('principalId'))) {
throw new BadRequestHttpException();
}

$newMemberToAdd = $doctrine->getRepository(Principal::class)->findOneById($request->get('principalId'));

if (!$newMemberToAdd) {
Expand Down Expand Up @@ -464,6 +469,10 @@ public function calendarShareAdd(ManagerRegistry $doctrine, Request $request, st
throw $this->createNotFoundException('Calendar not found');
}

if (!is_numeric($request->get('principalId'))) {
throw new BadRequestHttpException();
}

$newShareeToAdd = $doctrine->getRepository(Principal::class)->findOneById($request->get('principalId'));
if (!$newShareeToAdd) {
throw $this->createNotFoundException('Member not found');
Expand Down

0 comments on commit 861d97b

Please sign in to comment.