Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login broken when user session contains other users tx_begroupsroles_role #24

Open
kitzberger opened this issue Sep 18, 2023 · 1 comment

Comments

@kitzberger
Copy link

kitzberger commented Sep 18, 2023

When simulating a user login via the users module the following happens in SwitchUserRoleHook->setUserGroup():

  • tx_begroupsroles_role is read from the session
  • tx_begroupsroles_role===null (that's the case when the user has never logged in) then tx_begroupsroles_groups is being calculated
  • the first one of these tx_begroupsroles_groups is set as the tx_begroupsroles_role in the session

When simulating another user (that hasn't logged in before!!) the session is still holding that tx_begroupsroles_role and this skips the dermination of tx_begroupsroles_groups and that leads to an error in https://github.com/IchHabRecht/begroups_roles/blob/master/Classes/Hook/SwitchUserRoleHook.php#L90

$possibleUsergroups = GeneralUtility::intExplode(',', $this->backendUser->user['tx_begroupsroles_groups'], true);

PHP Runtime Deprecation Notice: explode(): Passing null to parameter #2 ($string) of type string is deprecated in GeneralUtility.php line 936

I believe that this error only occurs when simulating users, not when users regularly log in and use the whole role-feature.

A possible solution might be to hook into the exit-simulation part (EXT:backend/Controller/SwitchUserController->exitSwitchUserAction()) and do this:

  $sessionObject->set('backuserid', null);
+ $sessionObject->set('tx_begroupsroles_role', null);
@baschny
Copy link

baschny commented Sep 18, 2023

👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants