Review main Merged

69635[BUGFIX] Extract switch user handling from EXT:beuser

Oli Bartsch CR +2 V +2 Hard +360 −255 updated 06/29/21, 14:15

Commit message

The switch user handling was previously placed in EXT:beuser,
more precisely in the BackendUserControllers' indexAction.
It was therefore necessary to link to the extbase based
controller with a mix of prefixed arguments and the non
prefixed "switchUser" argument. Latter was internally
evaluated with GU:_GP(). This means, switching users was
done via GET requests in an extbase action, but only in
case a non extbase prefixed argument was set.

In #94209 this got worse when the BackendUserGroupController
was merged into BackendUserController. Since this controller
features a "remember my last action" functionality, switch user
could no longer reliably be triggered. The evaluation of the
non extbase prefixed "switchUser" argument only took place in
the "user listing" (indexAction) and the success of the call
therefore depended on the users' last called action, as this
action was automatically used.

This patch now extracts the switch user functionality from
EXT:beuser into a dedicated EXT:backend controller, featuring
two ajax routes "/switch/user" and "/switch/user/exit". Both
accessible via POST requests only. To trigger those requests,
a new JS module "TYPO3/CMS/Backend/SwitchUser" is introduced.
This also allows to completely remove the logout hook by using
the concrete markup (custom element) for the "exit" button.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Benni Mack +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 2

Files 14

Review log 1115

  1. Oli Bartsch uploaded patch set 1 06/28/21, 15:08

  2. core-ci voted on patch set 1 V -1 06/28/21, 15:20 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12775

  3. Oli Bartsch uploaded patch set 2 06/28/21, 17:43

  4. core-ci voted on patch set 2 V +1 06/28/21, 17:54 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12780

  5. Oli Bartsch uploaded patch set 3 06/29/21, 08:59

  6. core-ci voted on patch set 3 V +1 06/29/21, 09:09 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12790

  7. Benni Mack commented on patch set 3 06/29/21, 09:30

    SwitchUser.ts:33

    typo3-backend-switch-user-button?
  8. Oli Bartsch commented on patch set 3 06/29/21, 11:36

    SwitchUser.ts:33 Reply

    As discussed, this module takes care of performing the necessary POST requests and is not tightly bound to a <button>.
  9. Christian Kuhn commented on patch set 3 06/29/21, 12:56

    SwitchUserController.php:39

    let's remove that dependency in the unit test and hardcode to 3 in unit, then make this protected or private.
  10. Oli Bartsch uploaded patch set 4 06/29/21, 13:09

  11. Oli Bartsch commented on patch set 4 06/29/21, 13:10

    SwitchUserController.php:39 Reply

    Done
  12. core-ci voted on patch set 4 V +1 06/29/21, 13:19 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12800

  13. Christian Kuhn voted on patch set 4 V +1 CR +1 06/29/21, 13:35

  14. Benni Mack voted on patch set 4 V +2 CR +2 06/29/21, 14:15

  15. Benni Mack merged patch set 5 06/29/21, 14:15