Page 1 of 1

Login by email

PostPosted: Fri Jun 13, 2008 7:30 am
by sophistry
Has anyone set up an ability for users to login using their email address instead of their username?

I'm hoping its something easy, but I'd like to hear if anyone else ahs done it.

Thanks,
sophistry

PostPosted: Mon Jun 16, 2008 2:29 pm
by shannah
Why not just use the email field as the username column.

E.g. if your users table has an email_address column, you would have something like the following in your conf.ini file:

Code: Select all
[_auth]
    users_table=users
    username_column=email_address
    password_column=password


-Steve

PostPosted: Mon Jun 16, 2008 2:41 pm
by sophistry
I ended up trying this, and it somewhat seems to work, but I'm trying to juggle some code and configurations to get authentication and permissions to act nice together, so I haven't had time to really check to make sure its working. I'd bet it would work, though.

I was trying to add some snippets to my Users.php under the appropriate table to make sure you couldn't create an account with a duplicate email address, and I'm trying to overcome some hurdles in that department. There's a host of information on this (and the weblite) site, so I've been sifting through those.

I always go back to the Web Auction source code for ideas, and am usually pleased with results, but I'm mostly just an armchair coder, so I'm trying to piece it all together. :)

Thanks again, Steve
sophistry

PostPosted: Mon Jun 16, 2008 2:55 pm
by shannah
make sure you couldn't create an account with a duplicate email address


If you make the email_address field unique in mysql, that should effectively prevent people from registering with a duplicate email address.

Also, can't remember if this is built in (if it isn't it should be), but Xataface should check to make sure the username is unique when the user registers. So if you set the email column as your username column, xataface should take care of this.... if not, then this is a bug that needs to be fixed.

-Steve

PostPosted: Mon Jun 16, 2008 7:20 pm
by sophistry
Good point, I wasn't even thinking of that. I just changed the email field to unique, that should take care of any issues. That might free me up to take out a number of things I had in the Users.php - which probably caused the registration problems. I'm still having an issue setting up permissions so Anonymous users have read_only access, logged in users can add/edit their own records in a 'favorites' table, and make sure registering users can't change their role. I think it's coming together, but just when I think I've got it ... anonymous users seem to have the ability to change anything. I'm going to look into it now, but if I have issues I'll come back and maybe find some more info on it.

Thanks

PostPosted: Tue Jun 17, 2008 7:29 pm
by sophistry
This does work, I just have to write something into .. Users.php maybe .. to give an error when trying to register an email that already exists in the table.

Otherwise, what file contains the information on the login page? I need to change Username: to Email:

PostPosted: Wed Jun 18, 2008 12:51 am
by Jean
Hi Sophistry,

You go into xataface/xataface/templates/
and you copy the file Dataface_Login_Prompt.html into %yourapplication%/templates/ .
May be you'll have to create this directory.
Then you edit this file and replace username by email.

Jean

PostPosted: Wed Jun 18, 2008 5:45 pm
by sophistry
I've copied /dataface/templates/Dataface_Login_Prompt.html into /templates, and edits to that file don't seem to be having an effect. Other templates files I've copied into /templates do override properly. I'm not sure why this is different.

PostPosted: Tue Jun 24, 2008 10:08 am
by shannah
I've copied /dataface/templates/Dataface_Login_Prompt.html into /templates, and edits to that file don't seem to be having an effect.


Sorry this one got lost in the mix. You are indeed working with the correct template. Have you successfully customized a xataface template before? (e.g. copied a template from the dataface templates folder into the application's templates folder). The reason I ask is to rule out the possibility that your custom template is in the wrong place or something.

-Steve