First, thank you to provide this alternative to Masquerade module.
Problem/Motivation
I'm not sure if it's a support request or a feature request.
Currently, it seems impossible to just masquerade as "Authenticated user".
Steps to reproduce
On the Masquerade as role config page, this role is not available and the legend of the role select indicates : "The anthenticated role is always automatically selected", but you have a choice to do in the list because the field is required.
So you can't just select the anthenticated role (see screenshot)
Proposed resolution
Is it possible to make this role appear in the list ?
| Comment | File | Size | Author |
|---|---|---|---|
| masquerade-role-authenticated-user.png | 87.58 KB | mitsuko |
Issue fork msqrole-3479911
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mitsuko commentedDigging a little deeper to see that this was the intended behavior.
So I opened a merge request to add this functionality.
As much as the private browser window do the trick for the anonymous role, it seems essential to me to be able to test as an "Authenticated user" only.
Comment #4
mitsuko commentedComment #5
randalv commentedHi @mitsuko,
I see your point, it would be useful to only masquerade as the authenticated role, however I think I'll fix it somewhat differently.
The authenticated role *should* always be selected, so removing it from the automatically selected roles might produce strange results.
I'll just remove the 'required' parameter from the roles selector, leaving the field empty will result to only the authenticated role being enabled.
That should cover every use case.
Comment #7
randalv commentedIt's been released in 1.0.18.
Thanks for your suggestion!
Comment #8
mitsuko commentedHi @randalv,
First, thanks for your response and your commits !
Overall, your way of solving the problem suits me very well. Even if I find the functionality is more implicit like that...
Just for my information, I don't understand your comment : "The authenticated role *should* always be selected, so removing it from the automatically selected roles might produce strange results.".
Other roles necessarily inherit the permissions given to the role "authenticated role", so if this role is selected or not makes no difference. Besides, when I tried with my patch, everything worked perfectly when I only selected the "content editor" role... but maybe I'm missing something in the code...
Once again, thank you !
Comment #9
randalv commentedHi @mitsuko,
I'm not entirely certain what the case was anymore but when I built this module, I ran into some strange behaviour when the authenticated role wasn't present.
I could test it again, but I figure it's not really important anymore.
In any case, the reason you didn't run into any such incidents is because with your patch, behind the scenes the module would still apply the authenticated role (even if you didn't select it) in the submit handler.
I think regarding the validation, we shouldn't worry about that anymore. Before it was deliberately made impossible to leave the role selectbox empty, so we had to double check in the validator to see if people didn't get around HTML validation and leave it empty anyway.
But since we now want it to be left empty when required, we don't need that extra validation anymore.
Any extra roles that are added through the inspector will also fail the form, since Drupal automatically handles that as invalid input as it wasn't in the form element's `#options` array.
Comment #10
mitsuko commentedHi @randalv,
Thanks for clarifying and adding the functionality in the last release 1.0.18.
It works like a charm and there is no reason to do more !
Kind regards