Login fails if both username and email fields are emails

Created on 7 August 2024, 5 months ago
Updated 23 August 2024, 4 months ago

Problem/Motivation

The \Drupal\mail_login\AuthDecorator::lookupAccount method checks if the $identifier is an email and, if so, only checks the email field in user queries.

This leads to a situation when users using the email address in the username (different from what's in the email field) aren't able to log in.

Steps to reproduce

1. Install the module, configure it to allow logging in with both username and email.
2. Create the user with username@test.com as username and email@test.com as email.
2. Log in using email@test.com, which succeeds.
3. Log out and log in using username@test.com.

Expected: log in successfully.
Actual: login failure.

Proposed resolution

Update the \Drupal\mail_login\AuthDecorator::lookupAccount method to also look for email values in the username field.
Also, it may be worth adding a configuration option to configure this behavior.

Remaining tasks

Review, decide if the configuration option is needed.

User interface changes

It would become possible to log in using email stored in username field.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024