views:

148

answers:

2

I'm using Zend_Auth with a "Database Table Authentication". What I want to do is allow the user to login with either a username or email address as the "identityColumn". How would I allow both. I'm stuck.

A: 

Authenticate twice (if needed) with 2 different Zend_Auth_Adapter_DbTable objects and add some logic to determine if the login is username or email by guessing if what type of login user provided so that you save one query for most of the cases.

michal kralik
This would do, but it's not a good design. You might want to use auth class elsewhere and you would copy this. DRY.
Tomáš Fejfar
+2  A: 

Extend and implement your own Auth Adapter and use query like "WHERE username = ? or email = ?" to get Auth result :)

Tomáš Fejfar
I would definitely implement my own auth adapter here. It's easier than you might think and you can copy/extend the DbTable adapter as appropriate
David Caunt
Thanks. I have one in place and just never thought of that.
Blake