From 44a0214187cd3d1eb455ae860dc9b68b2bec30c0 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Sun, 11 Aug 2024 02:45:31 +0200 Subject: [PATCH] Fix --- src/Service/League/updateLeague/HandleUpdateLeague.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Service/League/updateLeague/HandleUpdateLeague.php b/src/Service/League/updateLeague/HandleUpdateLeague.php index 26e7ffcf..0fef936c 100644 --- a/src/Service/League/updateLeague/HandleUpdateLeague.php +++ b/src/Service/League/updateLeague/HandleUpdateLeague.php @@ -4,6 +4,7 @@ namespace DMD\LaLigaApi\Service\League\updateLeague; use DMD\LaLigaApi\Dto\LeagueDto; use DMD\LaLigaApi\Entity\League; +use DMD\LaLigaApi\Entity\User; use DMD\LaLigaApi\Repository\CustomRoleRepository; use DMD\LaLigaApi\Repository\LeagueRepository; use DMD\LaLigaApi\Repository\UserRepository; @@ -32,8 +33,13 @@ class HandleUpdateLeague { $this->authorizeRequest->authorizeLeaguePresident($leagueId); $user = $this->security->getUser(); + if (!$user instanceof User) + { + throw new HttpException(Response::HTTP_UNAUTHORIZED, 'User not found'); + } $leagueEntity = $this->leagueRepository->find($leagueId); $leagueDto = new LeagueDto(); + $leagueDto->presidentId = $user->getId(); $leagueDto->fillFromObject($leagueEntity); $leagueDto->fillFromArray($request->toArray()); $leagueDto->validate();