would like AuthComponent to use ['Contact']['email'] for the username
field and ['User']['pass'] for passwords. User hasOne Contact. These
are the methods I have tried without success:
Method #1 - Try and use Contact.email in both Controller & View
Controller (beforeFilter()):
$this->Auth->fields = array('username' => "Contact.email",'password'
=> "pass");
Login View:
echo $form->create('User', array('action' => 'login'));
echo $form->input('Contact.email');
echo $form->input('pass',array('type' => 'password'));
Result:
Returns invalid user/pass error. Debug SQL output shows that no query
was sent, simply failing without even querying DB.
Method #2 - Try using Contact.email in View but simply email in
Controller
Controller (beforeFilter()):
$this->Auth->fields = array('username' => "email",'password' =>
"pass");
Login View:
echo $form->create('User', array('action' => 'login'));
echo $form->input('Contact.email');
echo $form->input('pass',array('type' => 'password'));
Result:
Same as Method #1, it fails yet still does not generate a query.
Method #3
Controller (beforeFilter()):
$this->Auth->fields = array('username' => "email",'password' =>
"pass");
Login View:
echo $form->create('User', array('action' => 'login'));
echo $form->input('email');
echo $form->input('pass',array('type' => 'password'));
Result:
This was the only method that actually produced a SQL query. The SQL
it generates is mostly correct, LEFT JOIN'ing the contact table to the
user table, however it is trying to pull User.email rather than
Contact.email , resulting in a MySQL error.
It would appear that the underlying issue here is that $this->Auth-
>fields is unwilling to accept Contact.email. I am not willing to
simply move the email field to the users table since storing the same
data twice is obviously not good DB design.
Is there any way to still use the core AuthComponent with this DB
schema? Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment