Log in with email address only I am looking for a concrete way to only allow logging in with email address only in Drupal 8. 

I have seen Login Email and Login EmailUsername modules, but both still allow for username login as well as email. 

I am looking only for email.

So far, I have come up with this in the interim - but something is not quite right. While I can trigger a form error, the form still submits and authentication is called. It should not submit if the entered value does not resemble an email address:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_user_login_form_alter(&amp;$form, FormStateInterface $form_state) {
  $form['name']['#type'] = 'email';
  $form['name']['#title'] = t('Email Address');
  $form['name']['#description'] = t('Enter your email address.');
  $form['name']['#element_validate'][] = 'mymodule_login_validate_user';
  $form['pass']['#description'] = t('Enter the password that accompanies your email address.');
}

/**
 * Custom validation handler for the form login.
 *
 * @param $form
 * @param $form_state
 * @return bool
 */
function mymodule_login_validate_user(&amp;$element, FormStateInterface $form_state) {
  $email_input = $form_state-&gt;getValue('name');

  if (!\Drupal::service('email.validator')-&gt;isValid($email_input)) {
    $form_state-&gt;setError($element, 'Please enter a valid email address.');
  }
}


I am also overriding the core user.auth service with my own - I will be generating usernames based on factors about the user (fetching information from a remote AMS).

Is there any way to avoid username in Drupal 8?

edit: Users cannot register on the Drupal site, and forgot password will be replaced with a link to the external AMS system.
It seems Login with Email only should solve that. At least worth a look how they managed to do that.


  This simple Drupal 8 module allows users to log in exclusively with
  their email address from the standard login form.
  
  Setup:
  
  Just enable the module.
  
  Recommended Modules:
  
  This module is based on the Login Email or Username module:
  https://www.drupal.org/project/login_emailusername