views:

326

answers:

3

Hi, I'm building a webapp with symgony1.4 and doctrine1.2, and I wanna use the sfDoctrineGuardPlugin, but I have a little problem.

sfDoctrineGuardPlugin is built to authenticate by username, but I need to change it to ask for an email.

Any idea how to do it?

+1  A: 

How about keeping sfDoctrineGuard as it is, using the existing username field, but saving emails into it. Your users would then login with their emails. The default field length is VARCHAR(128) which is plenty for any email. If I remember right, the only thing you'd need to tweak is the form label for sfguard signup, signin, etc (wherever you display it). You'd basically just say "Enter email here" instead of saying "Enter username here".

The only downside is that you lose the "username", but you could always put that in a separate profile that's related to sfGuardUser.

If you don't like that approach, you can always tweak the sfDoctrineGuardPlugin code directly, but it's probably going to cause some headache.

Tom
Validations would be wrong, and names would be also wrong all over the code... I prefer not to do that.
alcuadrado
Your downvote isn't justified. You can override the validation very easily by adding custom validation on top. And you never specified you wanted to keep usernames intact.
Tom
+2  A: 

http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/

This has been written for propel, but probably is easily applicable with doctrine.

Maerlyn
I did something more or less like that
alcuadrado