fix : allow admin users to create client tickets on any project

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 20:07:19 +01:00
parent 0c8fb654a9
commit 6d7e6f5f48

View File

@@ -35,17 +35,20 @@ final readonly class ClientTicketNumberProcessor implements ProcessorInterface
$user = $this->security->getUser();
assert($user instanceof User);
if (null === $user->getClient()) {
throw new AccessDeniedHttpException('Only client users can create tickets.');
}
$project = $data->getProject();
if (null === $project) {
throw new BadRequestHttpException('Project is required.');
}
if (!$user->getAllowedProjects()->contains($project)) {
throw new AccessDeniedHttpException('You do not have access to this project.');
// Admins can create tickets on any project; clients only on allowed projects
if (!$this->security->isGranted('ROLE_ADMIN')) {
if (null === $user->getClient()) {
throw new AccessDeniedHttpException('Only client users can create tickets.');
}
if (!$user->getAllowedProjects()->contains($project)) {
throw new AccessDeniedHttpException('You do not have access to this project.');
}
}
$nextNumber = $this->clientTicketRepository->findNextNumberForProject($project);