Adjust Admin Logic
This commit is contained in:
parent
1516e8c890
commit
9257709605
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Entity\Organizations;
|
||||||
use App\Entity\Roles;
|
use App\Entity\Roles;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\UserOrganizatonApp;
|
use App\Entity\UserOrganizatonApp;
|
||||||
|
|
@ -88,10 +89,10 @@ class UserService
|
||||||
if (!$skipSelfCheck && $user->getUserIdentifier() === $this->security->getUser()->getUserIdentifier()) {
|
if (!$skipSelfCheck && $user->getUserIdentifier() === $this->security->getUser()->getUserIdentifier()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$userOrganization = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
|
$userOrganizations = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
|
||||||
if ($userOrganization) {
|
if ($userOrganizations) {
|
||||||
foreach ($userOrganization as $uo) {
|
foreach ($userOrganizations as $uo) {
|
||||||
if ($this->isAdminOfOrganization($uo)) {
|
if ($this->isAdminOfOrganization($uo->getOrganization())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -113,10 +114,10 @@ class UserService
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function isAdminOfOrganization(UsersOrganizations $usersOrganizations): bool
|
public function isAdminOfOrganization(Organizations $organizations): bool
|
||||||
{
|
{
|
||||||
$actingUser = $this->getUserByIdentifier($this->security->getUser()->getUserIdentifier());
|
$actingUser = $this->getUserByIdentifier($this->security->getUser()->getUserIdentifier());
|
||||||
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findOneBy(['users' => $actingUser]);
|
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findOneBy(['users' => $actingUser, 'organization' => $organizations]);
|
||||||
$roleAdmin = $this->entityManager->getRepository(Roles::class)->findOneBy(['name' => 'ADMIN']);
|
$roleAdmin = $this->entityManager->getRepository(Roles::class)->findOneBy(['name' => 'ADMIN']);
|
||||||
if ($uo) {
|
if ($uo) {
|
||||||
$uoa = $this->entityManager->getRepository(UserOrganizatonApp::class)->findOneBy(['userOrganization' => $uo,
|
$uoa = $this->entityManager->getRepository(UserOrganizatonApp::class)->findOneBy(['userOrganization' => $uo,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue