Skip to content

Login broken when user session contains other users tx_begroupsroles_role #24

@kitzberger

Description

@kitzberger

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions