# LoginEngine: using email addresses as logins?

**URL:** <https://www.ruby-forum.com/t/loginengine-using-email-addresses-as-logins/102131>\
**Category:** Engines\
**Created:** [August 11, 2006, 6:02am UTC](https://www.ruby-forum.com/t/loginengine-using-email-addresses-as-logins/102131 "2006-08-11T06:02:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwfrank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f1d935/32.png) [@dwfrank](https://www.ruby-forum.com/u/dwfrank)\
**Post date:** [August 11, 2006, 6:02am UTC](https://www.ruby-forum.com/t/loginengine-using-email-addresses-as-logins/102131/1 "2006-08-11T06:02:50Z")

</div>

Didn’t see this on the list anywhere, so I figured I’d bring it up.

LoginEngine has a separate concept of login id & email address, as well  
as fields for firstname and lastname.

For my app I was considering having no first/last storage and using  
email addresses as logins – or at least allowing email address to be  
the ID a user uses (there certainly is value in allowing an account to  
switch email address values over time).

Has there ever been any discussion about having this as an option for  
LoginEngine? Or is this custom enough that I should just DRY it?

–dwf

---

<div class="post-metadata">

**Author:** ![dwfrank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f1d935/32.png) [@dwfrank](https://www.ruby-forum.com/u/dwfrank)\
**Post date:** [August 11, 2006, 2:27pm UTC](https://www.ruby-forum.com/t/loginengine-using-email-addresses-as-logins/102131/2 "2006-08-11T14:27:53Z")

</div>

DWFrank wrote:

> For my app I was considering having no first/last storage and using  
> email addresses as logins – or at least allowing email address to be  
> the ID a user uses (there certainly is value in allowing an account to  
> switch email address values over time).

We have exactly the same requirement here, so I’d be interested too to  
see if we can use LE for this…

d

---

<div class="post-metadata">

**Author:** ![dwfrank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f1d935/32.png) [@dwfrank](https://www.ruby-forum.com/u/dwfrank)\
**Post date:** [August 15, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/loginengine-using-email-addresses-as-logins/102131/3 "2006-08-15T14:16:45Z")

</div>

DWFrank wrote:

> For my app I was considering having no first/last storage

I don’t believe the firstname and lastname fields are required.  
Therefore you could just drop them from the schema. Obviously you will  
need to override the signup template to not ask for these fields. This  
is just speculation since my app is accepting first and last name.

> and using  
> email addresses as logins – or at least allowing email address to be  
> the ID a user uses (there certainly is value in allowing an account to  
> switch email address values over time).

I did the following in my user model to handle this:

class User \< ActiveRecord::Base  
# Mixin free user functionality from login engine  
include LoginEngine::AuthenticatedUser

```
# Username should always match email address
before_validation do |r|
	r.login = r.email
end

```

end

This way anytime the email address is changed the login name will change  
also automatically. I just adjusted all templates to say “Email Address”  
instead of “User ID” (or whatever the old label was). Internally the  
login field is still used but from the user’s perspective they are only  
managing an email address.

Eric
