See #2861178-7: Optionally allow login and registration with (only) e-mail, the idea is to split up the validation and user login/registration creating, so that it's easy to customize certain parts of it without having to copy 80+ lines of code.

PR coming up a in a minute.

Comments

Berdir created an issue. See original summary.

berdir’s picture

berdir’s picture

StatusFileSize
new12.17 KB

Reroll, just as a patch for now. I can update the MR if including this is has a chance to get in.

Had a few tricky conflicts as I'm moving whole chunks around, but I hope I got all the changes.

Here's an example subclassed method that shows what we did. I saw that apparently there's support for the register form display. It looks like one thing that might no longer be required is the extra fields we added for terms & conditions as well as the region selection, but we also use the mail as username, so I assume that still needs to be there (which is it started in our project and then more things were added.

  protected function getAndValidateRegisterUserValues(array &$pane_form, FormStateInterface $form_state) {

    $values = $form_state->getValue($pane_form['#parents']);
    if (empty($values['register']['foo_terms'])) {
      $form_state->setError($pane_form['register']['foo_terms'], $this->t('The AGB must be accepted.'));
      return NULL;
    }

    if ($user_values = parent::getAndValidateRegisterUserValues($pane_form, $form_state)) {

      $user_values['name'] = $user_values['mail'];
      if (!empty($values['register']['foo_my_region_ref'])) {
        $user_values['foo_my_region_ref'] = $values['register']['foo_my_region_ref'];
      }

      $user_values['foo_terms'] = TRUE;
      return $user_values;
    }
  }
berdir’s picture

StatusFileSize
new11.24 KB

Oh, looks like that register form stuff isn't released yet, so here's a reroll against 8.x-2.11 for now.

Status: Needs review » Needs work

The last submitted patch, 4: commerce-user-login-split-2870783-4.patch, failed testing. View results