Handle permission
This commit is contained in:
parent
a10b499522
commit
6446eb2ce1
|
|
@ -38,9 +38,16 @@ class UserController extends AbstractController
|
|||
if ($this->isGranted('ROLE_SUPER_ADMIN')) {
|
||||
$usersByOrganization = $entityManager->getRepository(UsersOrganizations::class)->getActiveUsersGroupedByOrganization();
|
||||
|
||||
} else {
|
||||
} else{
|
||||
$userIdentifier = $this->getUser()->getUserIdentifier();
|
||||
if (!$userIdentifier) {
|
||||
return $this->redirectToRoute('app_login');
|
||||
}
|
||||
$organizations = $this->entityManager->getRepository(UsersOrganizations::class)->findOrganizationsByUserEmailAndRoleName($userIdentifier, 'ADMIN');
|
||||
if(!$organizations) {
|
||||
// if user is not admin in any organization, throw access denied
|
||||
throw $this->createNotFoundException(self::ACCESS_DENIED);
|
||||
}
|
||||
$usersByOrganization = $this->entityManager->getRepository(UsersOrganizations::class)
|
||||
->findActiveUsersByOrganizations($organizations);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue