b13 / menus

TYPO3 Extension for creating fast menus in a fast fashion
GNU General Public License v2.0
54 stars 21 forks source link

usergroup of current frontend user is not being respected #72

Closed iammati closed 2 months ago

iammati commented 2 years ago

I've noticed that the call here https://github.com/b13/menus/blob/master/Classes/Domain/Repository/MenuRepository.php#L156-L162 to get the generated menu as array is not generating a proper SQL expression for the current logged-in frontend user.

I'd have to implement this:

$usergroup = $GLOBALS['TSFE']->fe_user->user['usergroup'];

$this->pageRepository->where_groupAccess = <<<SQL
    AND ((`pages`.`fe_group` IN ({$usergroup}))
    OR (`pages`.`fe_group` = '')
    OR (`pages`.`fe_group` IS NULL)
    OR (`pages`.`fe_group` = '0'))
SQL;

since the current $this->pageRepository->where_groupAccess returns me the same SQL expression just as my custom one with the only difference that AND ((pages.fe_groupIN ({$usergroup})) is NOT presence.

I'm not aware about TYPO3's core where it's actually defining the where_groupAccess to the $GLOBALS (or using UserAspect or whatsoever) but in my (rare, I assume) use-case I'd need such implementation since my frontend login is underlying an AJAX call via middleware. OTOH the MenuRepository is being called post the whole middleware stack has been iterated through.

In the current state I'd need to fork the whole extension and adjust this or perform a composer-patch but I guess it's either fundamentally missing something in the core or my own configuration is wrong...

Would appreciate any information about this! :)

bmack commented 2 years ago

Hey @iammati ,

what TYPO3 version are you using?

iammati commented 2 years ago

Hey @iammati ,

what TYPO3 version are you using?

TYPO3 11.5 with PHP 8

achimfritz commented 2 months ago

Hi @iammati can this issue be closed? (s. frontend test that verifies correct behaviour https://github.com/b13/menus/pull/81/commits/32e5e349691da1e740741bc98dd5c0d2e00da24d). if not please give an detailed example, when this is not working