Comments

joekers created an issue. See original summary.

joekers’s picture

Status: Active » Needs review
StatusFileSize
new2.83 KB

Status: Needs review » Needs work

The last submitted patch, 2: allow_username_on_the-2927109-1.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new2.83 KB

That patch is corrupted.

claudiu.cristea’s picture

Status: Needs review » Needs work

Works well. Just some nits:

  1. +++ b/config/install/email_registration.settings.yml
    @@ -1 +1,2 @@
    +allow_username_registration: FALSE
    

    In Yaml syntax TRUE/FALSE should be lowercased. Please change also the line above if we're always touch the file.

  2. +++ b/config/schema/email_registration.schema.yml
    @@ -5,3 +5,6 @@ email_registration.settings:
    +      label: 'Allow users to log in with e-mail or username.'
    

    Maybe "Allow also username login" or "Allow login also with username"?

  3. +++ b/email_registration.module
    @@ -193,6 +195,12 @@ function email_registration_form_user_admin_settings_alter(&$form, FormStateInte
    +    '#description' => t('If ticked, a text entry field will be displayed on the new user registration form to allow users to enter their desired user name.'),
    

    s/ticked/checked

joekers’s picture

Only just seen this! Thanks for the feedback I'll update the patch ASAP.

joekers’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB

1. Updated.
2. Updated with "Allow login also with username".
3. I wasn't sure what you meant by "s/ticked/checked" so I updated "ticked" to "checked".

Hopefully this patch isn't corrupt too.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Great. Thank you!

andypost’s picture

Assigned: joekers » Unassigned
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Good idea but it needs test coverage before getting in

pfrenssen’s picture

StatusFileSize
new2.84 KB

Rerolled against latest HEAD.

pfrenssen’s picture

StatusFileSize
new3.18 KB

Rerolled against latest HEAD.

andypost’s picture

It needs upgrade hook as well

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.1 KB
new7.53 KB

@andypost, here are the update path & tests.

claudiu.cristea’s picture

The failure was cause because Drupal 8.8.x ran on PHP 5. This not possible anymore.

greggles’s picture

I've adjusted testing for the project to use PHP 7 for the future. Thanks for your help, claudiu.cristea!

greggles’s picture

StatusFileSize
new7.61 KB

Here's a reroll as the change to config/schema/email_registration.schema.yml didn't apply.

Also I'm not sure about this text:

+    allow_username_registration:
+      type: boolean
+      label: 'Allow login also with username.'

Shouldn't the label be "Allow registration also with username." ?

andypost’s picture

Status: Needs review » Needs work

Yep it needs better naming as well as update hook should become hook_post_update_NAME()

  1. +++ b/email_registration.install
    @@ -33,3 +33,12 @@ function email_registration_update_8100() {
    +function email_registration_update_8101() {
    +  \Drupal::configFactory()->getEditable('email_registration.settings')
    

    better to use hook_post_update_NAME() for config updates

  2. +++ b/email_registration.module
    @@ -122,11 +122,14 @@ function email_registration_cleanup_username($name) {
     function email_registration_form_user_form_alter(&$form, FormStateInterface $form_state) {
    ...
    +  if (!\Drupal::config('email_registration.settings')->get('allow_username_registration')) {
    +    $form['account']['name']['#type'] = 'value';
    

    the config name is confusing, maybe kind of "alter_user_form"

greggles’s picture

Thanks for the feedback, andypost!

I researched hook_post_update on the doc page and this stackexchange post. It seems config/content entities are best to update via hook_post_update_NAME in part because of the order it runs and how to run it.

andypost’s picture

The great side of post update hooks is less collision in patches comparing to hook_update_n

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new1.46 KB
new7.66 KB

Shouldn't the label be "Allow registration also with username." ?

and

the config name is confusing, maybe kind of "alter_user_form"

Finally I opted for this name:

require_username_on_registration:
  type: boolean
  label: 'Require also the username on registration'

Moved the update path to post update.

edysmp’s picture

StatusFileSize
new7.95 KB

Rerolled against latest HEAD.

edysmp’s picture

StatusFileSize
new7.95 KB

Fix syntax error in rerolled.

shabana.navas’s picture

StatusFileSize
new8.14 KB

Re-rolling patch as it wasn't applying to latest version.

rymcveigh’s picture

I know this is an older issue but it seems to be in a resolved state at this point. With the current 8.x release, to allow for anonymous users to edit/set their user name you just need to give the anonymous user permission to "change own username". Can others confirm that this issue is resolved?

greggles’s picture

The patch here still applies to 8.x-1.x branch tip, so it has not been merged. It would be great if anyone interested in this feature could articulate how this is different than what is possible in core.

rymcveigh’s picture

Status: Needs review » Reviewed & tested by the community

It seems this is needed if you want the Username field to be empty when the user first visits the registration form. I can confirm that the most recent patch posted in #23 works with the current development version of this module.

greggles’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, Ryan for that feedback and everyone along the way for your work on this issue!

Now fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.