Allow users to login using either their username OR their e-mail address

birdmanx35 - January 21, 2007 - 06:36
Project:Drupal
Version:8.x-dev
Component:user system
Category:feature request
Priority:normal
Assigned:wmbetts
Status:needs work
Description

Part of a series of reforms for the login system, this patch would ideally allow users to login using either their username OR their e-mail address, a feature that has previously been provided by the LoginToboggan module.

The login functionality applies to all Drupal installs, and this usability feature seems to me to be applicable to all Drupal installs and therefore the 6.x-dev core.

NOTE: I have no coding skills whatsoever, however, I hope I can contribute my ideas and hopes to Drupal.

#1

jjeff - January 21, 2007 - 13:46

+1 on concept.

#2

hickory - January 29, 2007 - 14:30

I would definitely find this useful - even an option that allowed users to *only* login with their email address.

#3

xweb - April 2, 2007 - 11:19

+1 / bump
Also for email only registration.

#4

catch - May 19, 2008 - 20:35
Version:6.x-dev» 7.x-dev
Priority:minor» normal

bumping to Drupal 7, and a +1 - this is increasingly standard behaviour on lots of different sites, and it would take little effort to implement.

#5

Shai - May 19, 2008 - 20:57

+1 on this idea.

I agree with hickory that we should go further than login toboggan. We should remove $user->name from the authentication process using $user->mail alone.

A side benefit to this is that it might make life less complicated for folks who are working very hard on an idea to bring screen name functionality into Drupal: http://drupal.org/node/102679.

Shai
content2zero

#6

wmbetts - May 21, 2008 - 01:50
Assigned to:Anonymous» wmbetts
Status:active» needs review

The attached patch allows users to login with either their email address or username. It seems to work fine for me, but I'd like other people to review it and report anything they see wrong with it. It's possible I missed something or didn't test a feature that other people use.

It should be noted I saved the patch in notepad before uploading it.
I also wrote this with 7.x-dev in mind.

AttachmentSizeStatusTest resultOperations
user.module.patch1.45 KBIgnoredNoneNone

#7

catch - May 21, 2008 - 14:49
Status:needs review» needs work

Haven't tested the patch, but it doesn't change any strings - the 'username' field would at a minimum have to be renamed to 'username or e-mail address'.

Additionally, why allow either value in the same field rather than making an extra 'e-mail' field and requiring either? I'm not sure which way is more common on the web and I think I've seen both.

#8

wmbetts - May 21, 2008 - 19:40

You're absolutely correct. I should have changed the field to say "Username or email address". I should have also changed the error message when someone supplies an invalid email, user name, or password.

Attached is a new patch. The patch does the following: validates users on either user name or email address, changes the login for to say "Username / Email Address", changes the invalid login error message to "Sorry, unrecognized username, email address , or password", and it changes the field max size from 60 to 64 reflecting the max sized allowed for the mail field in the database.

I'm not 100% sure if I should change the form field name from name or not.

I save the patch in notepad2 in UNIX format at the recommendation of more experienced developers.

AttachmentSizeStatusTest resultOperations
user.module.patch2.52 KBIgnoredNoneNone

#9

wmbetts - May 21, 2008 - 21:27
Status:needs work» needs review

I forgot to change the status.

#10

moshe weitzman - May 22, 2008 - 15:16

@catch - one textfield is less clutterring than two. so i like the approach proposed here.

but it is disruptive for modules that run validators and such to not know if they have been supplied an email or a password. i recommend that we add a #process or #element_validate to the name textfield and do the query if needed to populate name with a real username if needed. that way, #element_validate and #process run before validors and submit functions so those will be unaffected. hope this makes sense.

#11

catch - May 22, 2008 - 16:35

One other thing is we'd probably need some kind of check and/or upgrade path for username@example.com logins provided by drupal/site_network module. The chances of a conflict are pretty slim, but not impossible.

Thinking about 1 vs. 2 fields, where I've used sites that use two, I often find myself squinting to check if there's little red stars next to either, so I'd be pretty happy with a single field overall.

#12

hickory - May 22, 2008 - 16:38

Single field is good: if there's an @, assume it's an email address, otherwise assume it's a username. That's what I've been doing with a separate module - it should work as @ isn't allowed in usernames.

#13

catch - May 22, 2008 - 20:25

hickory, @ is allowed in usernames. Try registering on groups.drupal.org with hickory@drupal.org

#14

R.Muilwijk - October 16, 2008 - 13:42
Status:needs review» needs work

For some clients of us we had to implement this. Wouldn't it be better to provide a login method setting so people can choose how the users have to login:

Username,
Email Address,
Both

Let me know your thoughts about this.

#15

philbar - May 5, 2009 - 22:57

+1

Subscribe

#16

lastcowboy - June 16, 2009 - 08:02

+1

Subscribe

#17

philbar - November 2, 2009 - 06:04

Is this going to make it into d7 core?

#18

philbar - November 2, 2009 - 06:06

See also: Email Registration

#19

webchick - November 2, 2009 - 06:43
Version:7.x-dev» 8.x-dev

Nope; unfortunately it's a new feature and we closed Drupal 7 for features back in September.

 
 

Drupal is a registered trademark of Dries Buytaert.