Commit 99785852 authored by M Andriansyah Nurcahya's avatar M Andriansyah Nurcahya Committed by Andrey Postnikov
Browse files

Issue #3037323 by andypost, JeroenT, andriansyah, saidatom: Remove usage of...

Issue #3037323 by andypost, JeroenT, andriansyah, saidatom: Remove usage of deprecated methods and functions
parent ce0b48a9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
    "name": "drupal/email_registration",
    "type": "drupal-module",
    "description": "Allows users to register with an email address as their username.",
    "license": "GPL-2.0+",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/email_registration",
    "minimum-stability": "dev",
    "authors": [
@@ -31,6 +31,9 @@
        "issues": "http://drupal.org/project/issues/email_registration",
        "source": "https://git.drupalcode.org/project/email_registration"
    },
    "require": {
        "drupal/core": "^8.7.7 || ^9"
    },
    "conflict": {
        "drupal/commerce": "<2.12"
    },
+1 −1
Original line number Diff line number Diff line
name: Email Registration
type: module
description: 'Allows users to register with an email address as their username.'
core: 8.x
core_version_requirement: ^8.7.7 || ^9
dependencies:
  - drupal:user
+9 −5
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ function email_registration_user_insert(UserInterface $account) {
  }

  // Ensure whatever name we have is unique.
  $new_name = email_registration_unique_username($new_name, $account->id());
  $new_name = email_registration_unique_username($new_name, (int) $account->id());

  $account->setUsername($new_name);
  if ($account->isValidationRequired() && !$account->validate()) {
@@ -131,7 +131,9 @@ function email_registration_form_user_form_alter(&$form, FormStateInterface $for

  // Provide a random user name only if we are creating a new user, i.e. this
  // is a registration.
  if ($form_state->getFormObject()->getEntity()->isNew()) {
  /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
  $form_object = $form_state->getFormObject();
  if ($form_object->getEntity()->isNew()) {
    $form['account']['name']['#value'] = 'email_registration_' . user_password();
  }
  $form['account']['mail']['#title'] = t('Email');
@@ -144,7 +146,7 @@ function email_registration_form_user_pass_alter(&$form, FormStateInterface $for
  $form['name']['#title'] = t('Email');
  // Only convert textfields to email fields. This field is a hidden value when
  // you are already logged in.
  if ($form['name']['#type'] == 'textfield') {
  if ($form['name']['#type'] === 'textfield') {
    // Allow client side validation of input format.
    $form['name']['#type'] = 'email';
    $form['name']['#maxlength'] = Email::EMAIL_MAX_LENGTH;
@@ -183,7 +185,9 @@ function email_registration_user_login_validate($form, FormStateInterface $form_
    elseif (!$config->get('login_with_username')) {
      $user_input = $form_state->getUserInput();
      $query = isset($user_input['name']) ? ['name' => $user_input['name']] : [];
      $form_state->setErrorByName('name', t('Unrecognized email address or password. <a href=":password">Forgot your password?</a>', [':password' => Url::fromRoute('user.pass', [], ['query' => $query])->toString()]));
      $form_state->setErrorByName('name', t('Unrecognized email address or password. <a href=":password">Forgot your password?</a>', [
        ':password' => Url::fromRoute('user.pass', [], ['query' => $query])->toString(),
      ]));
    }
  }
}
@@ -205,7 +209,7 @@ function email_registration_form_user_admin_settings_alter(&$form, FormStateInte
/**
 * Submit function for user_admin_settings to save our variable.
 *
 * @see email_registration_form_user_admin_settings_alter().
 * @see email_registration_form_user_admin_settings_alter()
 */
function email_registration_form_user_admin_settings_submit(array &$form, FormStateInterface $form_state) {
  $config = \Drupal::configFactory()->getEditable('email_registration.settings');