- Issue created by @mitsuko
- 🇫🇷France mitsuko
Digging a little deeper to see that this was the intended behavior. 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.
- 🇧🇪Belgium RandalV
Hi @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.
- 🇧🇪Belgium RandalV
It's been released in 1.0.18.
Thanks for your suggestion! - 🇫🇷France mitsuko
Hi @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, and there is potentially the risk that the user validates the form without choosing any role...
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 !
- 🇧🇪Belgium RandalV
Hi @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.
- 🇫🇷France mitsuko
Hi @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
Automatically closed - issue fixed for 2 weeks with no activity.