Login_engine - auth against email rather that username?

Hi all,

Short of hacking the code apart, is there a method making the
login_engine authenticate against email address rather than username?

I find that people rarely remember usernames, and would prefer to use
email addresses as the identifier.

Thanks!

Tom

Simple fix would be to remove the email field from the
app/view/signup.rhtml
and rename the username field to email in the text.

What they put into the username field doesn’t much make a difference, as
long as it is a string.

-Nb

 Nathaniel S. H. Brown                           http://nshb.net

I think you have do a couple more things because the user model won’t
validate if a login is not provided.

I just re-included the LoginEngine::AuthenticatedUser module in my
User model and commented out the following lines:

We aren’t using the login and need to comment it out

validates_presence_of :login, :on => :create

validates_length_of :login, :within => 3…40, :on => :create

validates_uniqueness_of :login, :on => :create

Cheers,

Derek

On 1/2/06, Nathaniel S. H. Brown [email protected] wrote:

> Hi all,
>


Derek H.
HighGroove Studios - http://www.highgroove.com
Atlanta, GA
Keeping it Simple.
404.593.4879

Hello Tom !

2006/1/2, Tom T. [email protected]:

Short of hacking the code apart, is there a method making the
login_engine authenticate against email address rather than username?

I simply added a before_validation filter that copies the email field
to the username field. Then, I lenghtened the login field to
accomodate E-Mails.

Hope that helps !

This is all probably indicative of a need to distinguish the ‘user
profile’ information (name, birthday, favourite colour) from the
actual authentication information (id & password/phrase).

Perhaps the real way forward is either/or/both of:

a) removing the extraneous information (currently the name and email*)
from the authentication system, and
b) giving developers a fairly intuitive means of defining their own
validations on the id field - or a means of selecting between a few
existing ones (login, email address, something else…)

The stealth-launched new site (http://rails-engines.org) has a link to
the Trac system.
Someone submit a ticket, close your eyes and click the heels of your
ruby slippers three times, and perhaps it might get done :wink:

  • james
  • note that removing the guarantee that one field will contain a valid
    email address means that email notification has to be reworked too.

Tom T. wrote:

Short of hacking the code apart, is there a method making the
login_engine authenticate against email address rather than username?

Hi all,

Thanks for your responses. I’ve managed to make it work by just simply
changing most instances of the ‘login’ variable to ‘email’ and
removing/tweaking the validation lines. The code isn’t very complex, and
a bit of following it all through did me some good.

In a future version, a flag in the config would be ideal, allowing you
to auth against whatever field you wanted.

Login_engine is great work though - saved me a lot of time writing my
own system!

Thanks again,

Tom

I was not inferring that he delete the login column and field, rather to
remove the email field and use the login field for both the email and
username.

I see under the validation that you would likely have to extend the
length_of below for the login field to more adequately compensate for
the
longer email addresses.

You still want to ensure that the email is unique, present,

So I suggest only modifying the following line in
LoginEngine::Authenticated
to the following.

    validates_length_of :login, :within => 5..255, :on => :create

Regards,
Nathaniel.

 Nathaniel S. H. Brown                           http://nshb.net