fix organization not loading
This commit is contained in:
parent
281e58c4a7
commit
0a88ad0bde
|
|
@ -42,7 +42,8 @@ export default class extends Controller {
|
|||
|
||||
ajaxResponse: (url, params, response) => response,
|
||||
paginationDataSent: { page: "page", size: "size" },
|
||||
paginationDataReceived: { last_page: "last_page" },
|
||||
paginationDataReceived: { last_page: "last_page",
|
||||
data: "data"},
|
||||
filterMode: "remote",
|
||||
|
||||
ajaxURLGenerator: function(url, config, params) {
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class OrganizationController extends AbstractController
|
|||
|
||||
// API endpoint to fetch organization data for Tabulator
|
||||
#[Route(path: '/data/{id}', name: 'data', methods: ['GET'])]
|
||||
public function data(Request $request): JsonResponse
|
||||
public function data(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||
|
||||
|
|
@ -324,15 +324,24 @@ class OrganizationController extends AbstractController
|
|||
$qb->andWhere('o.email LIKE :email')
|
||||
->setParameter('email', '%' . $filters['email'] . '%');
|
||||
}
|
||||
if(!$this->isGranted('ROLE_SUPER_ADMIN')) {
|
||||
if (!$this->isGranted('ROLE_SUPER_ADMIN')) {
|
||||
$actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $actingUser]);
|
||||
|
||||
$allowedOrgIds = [];
|
||||
foreach ($uo as $item) {
|
||||
if($this->userService->isAdminOfOrganization($item->getOrganization())) {
|
||||
$qb->andWhere('o.id = :orgId')
|
||||
->setParameter('orgId', $item->getOrganization()->getId());
|
||||
if ($this->userService->isAdminOfOrganization($item->getOrganization())) {
|
||||
$allowedOrgIds[] = $item->getOrganization()->getId();
|
||||
}
|
||||
}
|
||||
|
||||
// If user has no organizations, ensure query returns nothing (or handle typically)
|
||||
if (empty($allowedOrgIds)) {
|
||||
$qb->andWhere('1 = 0'); // Force empty result
|
||||
} else {
|
||||
$qb->andWhere('o.id IN (:orgIds)')
|
||||
->setParameter('orgIds', $allowedOrgIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue