Fix
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-08-11 02:45:31 +02:00
parent 3837744b03
commit 44a0214187
1 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace DMD\LaLigaApi\Service\League\updateLeague;
use DMD\LaLigaApi\Dto\LeagueDto; use DMD\LaLigaApi\Dto\LeagueDto;
use DMD\LaLigaApi\Entity\League; use DMD\LaLigaApi\Entity\League;
use DMD\LaLigaApi\Entity\User;
use DMD\LaLigaApi\Repository\CustomRoleRepository; use DMD\LaLigaApi\Repository\CustomRoleRepository;
use DMD\LaLigaApi\Repository\LeagueRepository; use DMD\LaLigaApi\Repository\LeagueRepository;
use DMD\LaLigaApi\Repository\UserRepository; use DMD\LaLigaApi\Repository\UserRepository;
@ -32,8 +33,13 @@ class HandleUpdateLeague
{ {
$this->authorizeRequest->authorizeLeaguePresident($leagueId); $this->authorizeRequest->authorizeLeaguePresident($leagueId);
$user = $this->security->getUser(); $user = $this->security->getUser();
if (!$user instanceof User)
{
throw new HttpException(Response::HTTP_UNAUTHORIZED, 'User not found');
}
$leagueEntity = $this->leagueRepository->find($leagueId); $leagueEntity = $this->leagueRepository->find($leagueId);
$leagueDto = new LeagueDto(); $leagueDto = new LeagueDto();
$leagueDto->presidentId = $user->getId();
$leagueDto->fillFromObject($leagueEntity); $leagueDto->fillFromObject($leagueEntity);
$leagueDto->fillFromArray($request->toArray()); $leagueDto->fillFromArray($request->toArray());
$leagueDto->validate(); $leagueDto->validate();