Fix bad error status

This commit is contained in:
tchapi 2022-11-26 23:25:05 +01:00
parent e05ee0a73d
commit 861d97b943

View File

@ -19,6 +19,7 @@ use Doctrine\Persistence\ManagerRegistry;
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;
@ -273,6 +274,10 @@ class AdminController extends AbstractController
*/
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) {
@ -464,6 +469,10 @@ class AdminController extends AbstractController
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');