Skip to content

Commit

Permalink
Merge pull request #2293 from dpfaffenbauer/issue/2290
Browse files Browse the repository at this point in the history
[ResourceBundle] fix Pimcore 10.6 compatibility to find Admin User
  • Loading branch information
dpfaffenbauer committed May 25, 2023
2 parents 64208d8 + 17ae0dc commit cc3e66f
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ protected function isGrantedOr403(): void
if ($this->metadata->hasParameter('permission')) {
$permission = sprintf('%s_permission_%s', $this->metadata->getApplicationName(), $this->metadata->getParameter('permission'));

/**
* @var User $user
*
* @psalm-var User $user
*/
$user = method_exists($this, 'getAdminUser') ? $this->getAdminUser() : $this->getUser();
$user = $this->getUser();

if (class_exists(\Pimcore\Security\User\User::class) && $user instanceof \Pimcore\Security\User\User) {
/**
* @psalm-suppress UndefinedClass, UndefinedInterfaceMethod
*/
$user = $user->getUser();
}
else if (class_exists(\Pimcore\Bundle\AdminBundle\Security\User\User::class) && $user instanceof \Pimcore\Bundle\AdminBundle\Security\User\User) {
/**
* @psalm-suppress UndefinedClass, UndefinedInterfaceMethod
*/
$user = $user->getUser();
}
else {
throw new \RuntimeException(sprintf('Unknown Pimcore Admin User Class given "%s"', get_class($user)));
}

if ($user->isAllowed($permission)) {
return;
Expand Down

0 comments on commit cc3e66f

Please sign in to comment.