When switching from role 1 (that is currently using a certain module, e.g. "forms") to role 2 (that is lacking that permission) there's an exception for TYPO3 11:
Access Error: You don't have access to this module.
This is due to the fact that after switching roles via AJAX a refresh of the current URL is trigger via EXT:begroups_roles/Resources/Public/JavaScript/Toolbar/RoleSwitcher.js.
Here's a quick'n'dirty workaround:
- document.location.reload();
+ document.location.assign('/typo3');
